lr35902ish racket
Go to file
2020-06-09 16:56:33 +12:00
old-code first commit 2020-06-09 14:50:42 +12:00
.gitignore unignored readme 2020-06-09 14:52:53 +12:00
README.md fixed readme formatting 2020-06-09 16:56:33 +12:00
vm.rkt first working vm 2020-06-09 16:53:59 +12:00

zybino: LR35902ish racket language

very early days for now.

in the racket repl (comments for reader comprehension, remove before running):

(run-vm #x150 #x150 #x16 ; start-address, end-memory-view-addr, number-bytes-view
   '(#x3E #x69           ; LD A, $69
     #x26 #x01           ; LD H, $01
     #x2E #x62           ; LD L, $62
     #x77                ; LD (HL), A
     #x2E #x5B           ; LD L, $5B
     #x36 #xE6           ; LD (HL), $E6  ($E6 is the opcode for XOR $xx)
     #x10                ; STOP          (this instruction @ address $015B)
     #xF0                ;               (non-instruction, will be arg for previous byte)
     #x2E #x63           ; LD L, $63
     #x77                ; LD (HL), A
     #x10                ; STOP
     ))

will evaluate to:

PC: $16, SP: $00, Flags: %00000000
BC: $0000, DE: $0000
HL: $0163, AF: $6000
(HL): $60
$0150 > $3e $69 $26 $01 $2e $62 $77 $2e $5b $36 $e6 $e6 $f0 $2e $63 $77 $10 $00 $69 $60 $00 $00 < $0165

here we can see the program loaded starting from address $0150, including the XOR instruction loaded to $015B during execution, and the $69 we loaded to memory, along with the result of XOR $F0 we loaded to memory, at $0162 and $0163 respectively.

notes

currently supported instructions are:

  • LD [reg], #imm
  • LD [reg], [reg]
  • XOR #imm
  • AND #imm
  • OR #imm
  • STOP
  • NOP

all other instructions treated as NOP