Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download
# file opened: lua_macro_arg2.asm1 0000 ; test the new way of lua `_c`/`sj.calc` function to do the define/macro_arg2 0000 ; substitution before the expression is evaluated, so using macro arguments3 0000 ; inside lua script should be now trivial, no more workaround through DEFINE.4 00005 0000 ; this still shows extra options of `sj.insert_label`, which are not shown in6 0000 ; official documentation. I'm not sure if these will stay for v2.x, so I'm7 0000 ; not adding them to docs, but you can learn about any hidden optional arguments8 0000 ; in sjasm/lua_sjasm.cpp file, tracking down the particular lua stub, and checking9 0000 ; how many arguments and types are parsed, and how they are used in the call10 0000 ; of internal sjasm function.11 0000 ; These are to stay in v1.x forever like this, unless there will be really serious12 0000 ; reason to modify them. For v2.x the main goal is to mostly keep them and make13 0000 ; them official, but som pruning/reorganization may happen, plus newer Lua version..14 000015 0000 MACRO testM arg1?16 0000 ~ LUA ALLPASS17 0000 ~ x = _c("arg1?") -- get value of evaluated macro argument18 0000 ~ -- if you want the macro argument without evaluation19 0000 ~ -- check "lua_macro_arg.asm" test for DEFINE workaround20 0000 ~ sj.insert_label("x", x, false, true) -- isUndefined=false, isDefl=true21 0000 ~ _pc("dw arg1?, x, "..x) -- check all three sources of input value22 0000 ~ -- _pc does it's own substitution, the label "x" should be set and lua "x"23 0000 ~ -- test _c a bit more for handling weird things...24 0000 ~ e1 = _c("/* ehm")25 0000 ~ e2 = _c("define arg1? xx") -- will emit error "Label not found: define" = OK26 0000 ~ e3 = _c("$FF&".._c("arg1?"))27 0000 ~ _pc("db /* e1, e2, e3 */ "..e1..","..e2..","..e3)28 0000 ~ ENDLUA29 0000 ~ .localMacroLabel: ; check which root the macro local label gets (should be per emit)30 0000 ENDM31 000032 0000 x = 8833 0000 BigLabel1:34 0000 testM 0x123434 0000 > LUA ALLPASS34 0000 ~ > x = _c("arg1?") -- get value of evaluated macro argument34 0000 ~ > -- if you want the macro argument without evaluation34 0000 ~ > -- check "lua_macro_arg.asm" test for DEFINE workaround34 0000 ~ > sj.insert_label("x", x, false, true) -- isUndefined=false, isDefl=true34 0000 ~ > _pc("dw arg1?, x, "..x) -- check all three sources of input value34 0000 ~ > -- _pc does it's own substitution, the label "x" should be set and lua "x"34 0000 ~ > -- test _c a bit more for handling weird things...34 0000 ~ > e1 = _c("/* ehm")34 0000 ~ > e2 = _c("define arg1? xx") -- will emit error "Label not found: define" = OK34 0000 ~ > e3 = _c("$FF&".._c("arg1?"))34 0000 ~ > _pc("db /* e1, e2, e3 */ "..e1..","..e2..","..e3)34 0000 34 12 34 12 >dw 0x1234, x, 466034 0004 34 12 >lua_macro_arg2.asm(25): error: [LUA] Label not found: definelua_macro_arg2.asm(34): ^ emitted from here34 0006 00 00 34 >db 0,0,5234 0009 > ENDLUA34 0009 >.localMacroLabel: ; check which root the macro local label gets (should be per emit)35 0009 .local1:36 0009 34 12 DW x ; check that symbol "x" was set by sj.insert_label37 000B 18 FC jr BigLabel1.local1 ; check "big" label was not modified by sj.insert_label38 000D x = 7739 000D BigLabel2:40 000D testM 0x345640 000D > LUA ALLPASS40 000D ~ > x = _c("arg1?") -- get value of evaluated macro argument40 000D ~ > -- if you want the macro argument without evaluation40 000D ~ > -- check "lua_macro_arg.asm" test for DEFINE workaround40 000D ~ > sj.insert_label("x", x, false, true) -- isUndefined=false, isDefl=true40 000D ~ > _pc("dw arg1?, x, "..x) -- check all three sources of input value40 000D ~ > -- _pc does it's own substitution, the label "x" should be set and lua "x"40 000D ~ > -- test _c a bit more for handling weird things...40 000D ~ > e1 = _c("/* ehm")40 000D ~ > e2 = _c("define arg1? xx") -- will emit error "Label not found: define" = OK40 000D ~ > e3 = _c("$FF&".._c("arg1?"))40 000D ~ > _pc("db /* e1, e2, e3 */ "..e1..","..e2..","..e3)40 000D 56 34 56 34 >dw 0x3456, x, 1339840 0011 56 34 >lua_macro_arg2.asm(25): error: [LUA] Label not found: definelua_macro_arg2.asm(40): ^ emitted from here40 0013 00 00 56 >db 0,0,8640 0016 > ENDLUA40 0016 >.localMacroLabel: ; check which root the macro local label gets (should be per emit)41 0016 .local2:42 0016 56 34 DW x43 0018 18 FC jr BigLabel2.local2 ; same checks as above, but second value44 001A# file closed: lua_macro_arg2.asmValue Label------ - -----------------------------------------------------------0x3456 x0x0000 X BigLabel10x0009 X 0>localMacroLabel0x0009 BigLabel1.local10x000D X BigLabel20x0016 X 1>localMacroLabel0x0016 BigLabel2.local2