Stackmaster-16 Emulator

We now have an instruction set and an assembler, but not processor yet.

To test them it is useful to have an emulator for the Stackmaster-16 so I wrote one called FPEmu.

It reads a .hex file, loads it into the emulated memory and starts executing the instructions from address 0x0000 and onward. While executing it shows the address and content of each instruction. The current version implements enough instructions to run the example program from the previous post.

It gives some idea what logic is needed to implement an instruction, this should come in handy during the hardware design.

The emulator will also be helpful later on when trying to debug games outside the actual hardware.

Running

./fpemu a.hex

where a.hex contains the assembled example program gives

Loading a.hex
0000 8000 ; NOP
0002 c000 ; LDL D 0X0000
0004 c001 ; LDL D 0X0001
0006 e010 ; ADD D
0008 b100 ; DUP D
000a c00a ; LDL D 0X000A
000c e310 ; GT
000e 1ff6 ; BIF LABEL1  (0004)
0010 8200 ; HALT
Loading completed
Running
0000 8000
0002 c000
0004 c001
0006 e010
0008 b100
000a c00a
000c e310
000e 1ff6
0004 c001
...
0004 c001
0006 e010
0008 b100
000a c00a
000c e310
000e 1ff6
0004 c001
0006 e010
0008 b100
000a c00a
000c e310
000e 1ff6
0010 8200
Processor halted
ExceptionCode: 0 (All is OK)
Last instruction: 8200

Next: FPGA Hello World