Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download
# file opened: lua_macro_arg.asm1 0000 ; OBSOLETE, define/macro_arg substitution is added to `_c`/`sj.calc` in v1.14.42 0000 ; check new test lua_macro_arg2.asm3 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 sj.insert_label, and it's extra undocumented optional arguments to keep9 0000 ; that global symbol of "DEFL" type (like "=" in asm source), so it can be10 0000 ; redefined over and over with new values11 0000 ; Also macro arguments are substituted inside Lua `_pl()` and `_pc()` (parse line,12 0000 ; parse code), but not 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 ~ sj.insert_label("x", x, false, true) -- isUndefined=false, isDefl=true20 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?") -- does NOT work. Should it?24 0000 ~ -- now substitution in `_c` WORKS in v1.14.425 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 ~ > sj.insert_label("x", x, false, true) -- isUndefined=false, isDefl=true32 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?") -- does NOT work. Should it?32 0000 ~ > -- now substitution in `_c` WORKS in v1.14.432 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 sj.insert_label35 0009 18 FC jr BigLabel1.local1 ; check "big" label was not modified by sj.insert_label36 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 ~ > sj.insert_label("x", x, false, true) -- isUndefined=false, isDefl=true38 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?") -- does NOT work. Should it?38 000B ~ > -- now substitution in `_c` WORKS in v1.14.438 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------ - -----------------------------------------------------------0x3456 x0x0000 X BigLabel10x0007 X 0>localMacroLabel0x0007 BigLabel1.local10x000B X BigLabel20x0012 X 1>localMacroLabel0x0012 BigLabel2.local2