drive/solve/solve.s
2022-06-11 17:12:06 -04:00

82 lines
905 B
ArmAsm

; vim: ft=nasm
%macro i_nop 0
db 0x00
%endmacro
%define np i_nop
%macro i_halt 1
db 0x01
db %1
%endmacro
%define ht i_halt
; load <mem> <value>
%macro i_load 2
db 0x10
db %1
db %2
%endmacro
%define ld i_load
; send <device> <mem>
%macro i_send 2
db 0x20
db %1
db %2
%endmacro
%define sd i_send
; get <mem> <device>
%macro i_get 2
db 0x21
db %1
db %2
%endmacro
%define gt i_get
; jlt <a>, <b>, <loc>
; a < b
%macro i_less 3
db 0x50
db %1
db %2
db %3
%endmacro
%define jl i_less
; jle <a>, <b>, <loc>
; a <= b
%macro i_leq 3
db 0x51
db %1
db %2
db %3
%endmacro
%define le i_leq
%define inp 0
%define disp 1
%define arith 2
%define tape 3
gt 0x00, inp
gt 0x01, inp
gt 0x02, inp
gt 0x03, inp
; [a, b, c, d] -> mem
sd tape, 0x00
sd tape, 0x01
sd tape, 0x02
sd tape, 0x03
; {a, b, c, d}
sd disp, 0x00
sd disp, 0x01