NodeCPU

NodeCPU is a “virtual computer” built in NodeJS. While ths isn’t exactly a proof-of-concept, it is still a bit of an experiment.

Instruction set

Opcode Name Description Notes
01 imm32 mov ra,imm8 Put an immediate into RA Executes on last byte of immediate
02 imm32 mov rb,imm8 Put an immediate into RB Executes on last byte of immediate
03 inc ra Increment RA by 1
04 inc rb Increment RB by 1
05 imm32 add imm32,ra Add immediate to RA Executes on last byte of immediate
06 imm32 add imm32,rb Add immediate to RB Executes on last byte of immediate
07 addr16 jmp addr16 Jump to an address in memory Executes on last byte of address

Memory map

Addr Desc
0x8000 End of memory
0x4000 Randomly Accessible Memory (RAM)
0x0000 Read-Only Memory (ROM) 1

General-purpose registers

Name Desc
RA Accumalator
RB Base

Definitions

Immediate: A value or address in memory 2 RAM: Randomly Accessible Memory ROM: Read-Only Memory

Footnotes

  1. Uses big endian

GitHub

View Github