| asm | feat: add poll instruction, add mouse support, use poll and mouse in conway | |
| vm | feat: add poll instruction, add mouse support, use poll and mouse in conway | |
| .gitignore | feat: get a small vm running a very simple program! | |
| isa.ods | feat: add poll instruction, add mouse support, use poll and mouse in conway | |
| main.ha | feat: regroup both executables in a single one with subcommands | |
| README.md | precise semantics of ISA | |
BunCPU
Key characteristics:
- 16 bit arithmetic
- 16 bit address bus
- 8 bit memory
- Von Neuman architecture (code and data live in the same place)
- Graphics mode (last 21600 bytes are graphics memory to a 240x180 4 bpp display)
Instruction Set
- 16 registers labelled r0 to r13 + rpc + rsp
- Arithmetic
- Logic
- Memory
- Stack (?)
- Jumping and branching
movb r0, r1
movw r0, r1
addb, 1, r0
setb, r0, r1 ; = movb r0, [r1]
getb, r0, r1 ; = movb [r0], r1
Flags and jumps
Arithmetic operations reset all flags, and set the overflow flag if it happens.
Comparison instructions reset all flags, and set the corresponding EQUAL, GREATER, or LESSER flags.
Those flags can be used to jump around with the j* instructions.
Unconditional jumps can be implemented by mov-ing an address into rpc.
Relative jumps can be implemented by add-ing and sub-ing from rpc.
For operations that can operate on 8 bit and 16 bit values (b and w suffix), the upper instruction bit is used to encode which one is used.
0b0xxxxxxx -> 8 bit instruction
0b1xxxxxxx -> 16 bit instruction
Executable format
Program code is placed at the start of memory (address 0x0).
Program data is placed right after it.
At the start of the program, the rsp register should be set to the start of the stack, to define the stack size.