| Ins | Description |
|---|---|
| : | copy the top stack entry |
| ! | drop the top stack entry |
| ~ | swap the top two stack entries |
| * | join the top two stack entries |
| S | display then drop the top stack entry |
| ^ | drop then run the top stack entry |
| a | enclose the top stack entry in parentheses |
| ( ) | add a new stack entry |
A combination of different factors make an interpreter for Underload an interesting project to tackle in Redcode:
- parsing single character instructions is easy, I don't like writing parsers
- handling variable length data can be tricky
- no operands / no side effects to worry about
- only 8 instructions, the size of the interpreter should be reasonable
- ^ is the only means of flow control
The final code weighs in at a mere 79 instructions. Here's the final version of the Underload Interpreter. If you have any improvements to suggest, please leave a comment below.
No comments:
Post a Comment