Rev 539 | Blame | Compare with Previous | Last modification | View Log | Download
# file opened: lua_macro_arg.asm1 0000 ; OBSOLETE *more*, v1.20.0: sj.get_define is now extended to search also macro arguments2 0000 ; OBSOLETE, define/macro_arg substitution is added to `_c`/`sj.calc` in v1.14.43 00004 0000 ; this test shows possible workaround for:5 0000 ; 1) extracting macro arg through regular DEFINE (to not tamper with current6 0000 ; "big" label from outside the macro, otherwise one can also set global label)7 0000 ; 2) how to store intermediate values into global labels from inside Lua script8 0000 ; with _pl creating full asm line with non-main DEFL type of label, so it can9 0000 ; be redefined over and over with new values (the sj.insert_label does produce10 0000 ; only regular labels, which can't change value multiple times.11 0000 ; Also macro arguments are substituted inside Lua `_pl()` and `_pc()` (parse line,12 0000 ; parse code), and inside `_c` (calculate expression)13 000014 0000 MACRO testM arg1?15 0000 ~ ; convert macro-define "arg1?" to global define (makes it visible to Lua)16 0000 ~ DEFINE __testM_arg1_tmp arg1?17 0000 ~ LUA ALLPASS18 0000 ~ x = sj.get_define("__testM_arg1_tmp")19 0000 ~ _pl("!x = "..x) -- DEFL type label "x" set to value x20 0000 ~ _pc("ld de,arg1?") -- _pc does the substitution21 0000 ~ sj.add_word(x) -- parsed value from lua variable22 0000 ~ sj.add_word(_c("x")) -- _c will at least recognize the inserted label23 0000 ~ z = _c("arg1?") -- now substitution in `_c` WORKS in v1.14.424 0000 ~ assert(x == sj.get_define("arg1?", true)) -- since v1.20.0 sj.get_define can also search macro arguments25 0000 ~ ENDLUA26 0000 ~ .localMacroLabel:27 0000 ~ UNDEFINE __testM_arg1_tmp ; release the global define28 0000 ENDM29 000030 0000 x = 8831 0000 BigLabel1:32 0000 testM 0x123432 0000 > ; convert macro-define "arg1?" to global define (makes it visible to Lua)32 0000 > DEFINE __testM_arg1_tmp arg1?32 0000 > LUA ALLPASS32 0000 ~ > x = sj.get_define("__testM_arg1_tmp")32 0000 ~ > _pl("!x = "..x) -- DEFL type label "x" set to value x32 0000 ~ > _pc("ld de,arg1?") -- _pc does the substitution32 0000 ~ > sj.add_word(x) -- parsed value from lua variable32 0000 ~ > sj.add_word(_c("x")) -- _c will at least recognize the inserted label32 0000 ~ > z = _c("arg1?") -- now substitution in `_c` WORKS in v1.14.432 0000 ~ > assert(x == sj.get_define("arg1?", true)) -- since v1.20.0 sj.get_define can also search macro arguments32 0000 >!x = 0x123432 0000 11 34 12 >ld de,0x123432 0003 34 12 34 12 > ENDLUA32 0007 >.localMacroLabel:32 0007 > UNDEFINE __testM_arg1_tmp ; release the global define33 0007 .local1:34 0007 34 12 DW x ; check that symbol "x" was set by _pl("!x = "..x)35 0009 18 FC jr BigLabel1.local1 ; check "big" label was not modified by _pl("!x = "..x)36 000B x = 7737 000B BigLabel2:38 000B testM 0x345638 000B > ; convert macro-define "arg1?" to global define (makes it visible to Lua)38 000B > DEFINE __testM_arg1_tmp arg1?38 000B > LUA ALLPASS38 000B ~ > x = sj.get_define("__testM_arg1_tmp")38 000B ~ > _pl("!x = "..x) -- DEFL type label "x" set to value x38 000B ~ > _pc("ld de,arg1?") -- _pc does the substitution38 000B ~ > sj.add_word(x) -- parsed value from lua variable38 000B ~ > sj.add_word(_c("x")) -- _c will at least recognize the inserted label38 000B ~ > z = _c("arg1?") -- now substitution in `_c` WORKS in v1.14.438 000B ~ > assert(x == sj.get_define("arg1?", true)) -- since v1.20.0 sj.get_define can also search macro arguments38 000B >!x = 0x345638 000B 11 56 34 >ld de,0x345638 000E 56 34 56 34 > ENDLUA38 0012 >.localMacroLabel:38 0012 > UNDEFINE __testM_arg1_tmp ; release the global define39 0012 .local2:40 0012 56 34 DW x41 0014 18 FC jr BigLabel2.local2 ; same checks as above, but second value42 0016# file closed: lua_macro_arg.asmValue Label------ - -----------------------------------------------------------0x0007 X 0>localMacroLabel0x0012 X 1>localMacroLabel0x0000 X BigLabel10x0007 BigLabel1.local10x000B X BigLabel20x0012 BigLabel2.local20x3456 x