4-bit virtual CPU
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

# Mistakes
## Don't design opcodes in your head
You WILL screw up and your binary encodings WILL overlap.
You definitely need some tool to design instruction opcodes
for anything more complicated than just 1-byte instructions.
Turned out this mistake propogates further when implementing
assembler.
## Load/store instructions MUST be able to use register as address
I have no idea how we didn't notice this mistake.
I guess it is not too bad for a CPU with 16 bytes of memory,
but for something bigger it is unacceptable.
## Jump instructions need more love
Jumping 3 instructions back and 7 forward is too limiting.
Seriously, that's stupid.
Also, in my current design, jumping offset of 0 will
move CPU to an infinite loop.
## Implementing assembler with regex is not fancy
It is probably easier to implement than writing proper
lexer/parser, but error reporting can be weird.
## Two registers are really not enough
Just imagine, you are trying to write a loop, you use
`R1` as your index variable and `R0` for your loop condition.
Now you have already ran out of registers and you didn't even
start writing loop body!