22 lines
1.1 KiB
Plaintext
22 lines
1.1 KiB
Plaintext
; nrjasm standard library starts here
|
|||
|
|
|
||
|
|
; custom macros always take 3 values, usually cell addresses (referred to as %A, %B and %C) and defined between .def and .end (no nesting allowed)
|
||
|
|
; custom macros are always expanded before the elementary macros
|
||
|
|
; if %C is not passed, it is replaced with NXT
|
||
|
|
; if %B and/or %A is not passed, it is replaced with HLT
|
||
|
|
|
||
|
|
.def .lbl ; define labels
|
||
|
|
.var %A FREE ; allocate a variable with the name in %A, then set it to the next instruciton address:
|
||
|
|
.set @%A NXT ; %A is directly substituted as text, so we can use it after the dereferencing operator
|
||
|
|
.end
|
||
|
|
|
||
|
|
; define a reusable buffer variable for our following macros
|
||
|
|
.var setbuf FREE ; we don't care which address it will actually be
|
||
|
|
|
||
|
|
.def MOV ; transfer one cell to another, usage: MOV dst src
|
||
|
|
@setbuf HLT NXT ; first, zero out the setbuf variable by performing NOR with 0xFFFF
|
||
|
|
%A HLT NXT ; then, zero out the destination cell by performing NOR with 0xFFFF
|
||
|
|
@setbuf %B NXT ; then, set setbuf variable to the inverted source value
|
||
|
|
%A @setbuf %C ; finally, set destination cell to the inverted setbuf value ( = source value)
|
||
|
|
.end
|