A bytecode vm written in python.
look at wiki for compiler instructions
note: the first two hex values of a CHex program are the magic number
Print the ascii hex character stored in memory at the offset given.
Equivelent of jump command in asm.
Store a value in memory at the given offset.
Jump to a program offset stored in memory.
Jump to given program offset if two values in memory are equal.
If you would like to see some code I have already written please check the example binary.
- It inits the memory.
- It inits the only register the cpu has. (offset)
- It loads the first two bytes of the program file and checks if they say "hi" in ascii. If not true it turns off.
- It sets offset to 0x02
- It gets the command at the location of offset and runs it.
- It sets offset to the next command
- Goes back to step 5 and repeats ntil the program ends.