stdlib.nrjasm (1124B)
1 ; nrjasm standard library starts here 2 3 ; 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) 4 ; custom macros are always expanded before the elementary macros 5 ; if %C is not passed, it is replaced with NXT 6 ; if %B and/or %A is not passed, it is replaced with HLT 7 8 .def .lbl ; define labels 9 .var %A FREE ; allocate a variable with the name in %A, then set it to the next instruciton address: 10 .set @%A NXT ; %A is directly substituted as text, so we can use it after the dereferencing operator 11 .end 12 13 ; define a reusable buffer variable for our following macros 14 .var setbuf FREE ; we don't care which address it will actually be 15 16 .def MOV ; transfer one cell to another, usage: MOV dst src 17 @setbuf HLT NXT ; first, zero out the setbuf variable by performing NOR with 0xFFFF 18 %A HLT NXT ; then, zero out the destination cell by performing NOR with 0xFFFF 19 @setbuf %B NXT ; then, set setbuf variable to the inverted source value 20 %A @setbuf %C ; finally, set destination cell to the inverted setbuf value ( = source value) 21 .end