New game uploaded: Core War
New game uploaded: Core War
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.
New game uploaded: Core War
Well, accommodating labels is a significant addition.
LABEL SUPPORT
Tokenizer, with little utility functions. DONE. 240 lines.
"Compiler", with little utility functions. IN PROGRESS. 66 lines.
Integrate.
Version "1.0" achieved.
The binary has grown from 14K to to 17K.
New game uploaded: Core War
LABEL SUPPORT
Tokenizer, with little utility functions. DONE. 240 lines.
"Compiler", with little utility functions. DONE. 80 lines.
Integrate.
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.
New game uploaded: Core War
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.
New game uploaded: Core War
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.
New game uploaded: Core War
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.
-
- Posts: 140
- Joined: Wed Jan 20, 2021 6:43 pm
New game uploaded: Core War
This is a cool project. Its really cool to see your thought-processes in your updates and the corresponding updates of your code. Thanks!