New game uploaded: Core War

All aspects of programming on the Commander X16.
rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New game uploaded: Core War

Post by rje »


I walked through one of the old redcode assemblers.  I didn't like it -- I felt the parsing was too generic, as if done as a programming exercise.  But it gave me ideas:

1. USE THE STRUCTURE

Redcode programs adhere to a set of rules that suggest a simple parser based on one line = one instruction.

2. TOKENS REQUIRED

Labels require token-like structures, because values are not yet finalized.

3. LOOK AHEAD

The first two tokens on a line, taken together, tell me half of what I need to know.

4. NUMERIC EXPRESSIONS

Don't bother until everything else is done and you're bored.

 

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New game uploaded: Core War

Post by rje »


Well, accommodating labels is a significant addition.

LABEL SUPPORT


  1. Tokenizer, with little utility functions.  DONE.  240 lines.


  2. "Compiler", with little utility functions.  IN PROGRESS.  66 lines.


  3. Integrate.


  4. Version "1.0" achieved.


The binary has grown from 14K to to 17K. 

 

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New game uploaded: Core War

Post by rje »


LABEL SUPPORT



  1. Tokenizer, with little utility functions.  DONE.  240 lines.


  2. "Compiler", with little utility functions.  DONE.  80 lines.


  3. Integrate.


  4. Version "1.0" achieved.




The binary grew to 18K, then backed off to 17K when I removed the original parsing hack.


I'm surprised how long the tokenizer routines are as a whole.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New game uploaded: Core War

Post by rje »


I've been thinking about how to speed up execution.

Core Wars runs plenty fast -- it doesn't feel labored, and warriors move at a pace that the human eye can keep up with, which is appropriate for visual interfaces.

But I'm always looking for little corners to cut.

 

Obviously the target is the execution loop.

One speedup might be to VERY judiciously assign a register variable.

The next might be some inline assembly, somehow.

 

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New game uploaded: Core War

Post by rje »


Labels now work.

However, the X16 bin is eating the first character in the first line of code.  This is AFTER the file load eats its obligatory two characters.

The UNIX bin does NOT eat the first character.   Therefore the bug is in the X16 code that reads bytes from Bank 1 into the char buffer. 

There's an off-by-one error here.

* * *

Found it.

rje
Posts: 1263
Joined: Mon Apr 27, 2020 10:00 pm
Location: Dallas Area

New game uploaded: Core War

Post by rje »


Went 1.0.

Added a "demo" mode for when I click "Try it out!"...

* * *

The code is really picky about file formats.  Special characters do upset us.  I may have to have a better sanitization function.

Snickers11001001
Posts: 140
Joined: Wed Jan 20, 2021 6:43 pm

New game uploaded: Core War

Post by Snickers11001001 »


This is a cool project.   Its really cool to see your thought-processes in your updates and the corresponding updates of your code.    Thanks!   

Post Reply