1
0
Fork
You've already forked buncpu
1
No description
2024年08月27日 17:32:29 +02:00
asm feat: add poll instruction, add mouse support, use poll and mouse in conway 2024年08月27日 17:32:29 +02:00
vm feat: add poll instruction, add mouse support, use poll and mouse in conway 2024年08月27日 17:32:29 +02:00
.gitignore feat: get a small vm running a very simple program! 2024年07月31日 21:06:21 +02:00
isa.ods feat: add poll instruction, add mouse support, use poll and mouse in conway 2024年08月27日 17:32:29 +02:00
main.ha feat: regroup both executables in a single one with subcommands 2024年08月18日 12:38:33 +02:00
README.md precise semantics of ISA 2024年08月04日 20:27:28 +02:00

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.