?login_element?

Subversion Repositories NedoOS

Rev

Rev 539 | Blame | Compare with Previous | Last modification | View Log | Download

# file opened: lua_macro_arg.asm
 1    0000                  ; OBSOLETE *more*, v1.20.0: sj.get_define is now extended to search also macro arguments
 2    0000                  ; OBSOLETE, define/macro_arg substitution is added to `_c`/`sj.calc` in v1.14.4
 3    0000
 4    0000                  ; this test shows possible workaround for:
 5    0000                  ; 1) extracting macro arg through regular DEFINE (to not tamper with current
 6    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 script
 8    0000                  ;   with _pl creating full asm line with non-main DEFL type of label, so it can
 9    0000                  ;   be redefined over and over with new values (the sj.insert_label does produce
10    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    0000
14    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 ALLPASS
18    0000 ~                        x = sj.get_define("__testM_arg1_tmp")
19    0000 ~                        _pl("!x = "..x)         -- DEFL type label "x" set to value x
20    0000 ~                        _pc("ld de,arg1?")      -- _pc does the substitution
21    0000 ~                        sj.add_word(x)          -- parsed value from lua variable
22    0000 ~                        sj.add_word(_c("x"))    -- _c will at least recognize the inserted label
23    0000 ~                        z = _c("arg1?")         -- now substitution in `_c` WORKS in v1.14.4
24    0000 ~                        assert(x == sj.get_define("arg1?", true))   -- since v1.20.0 sj.get_define can also search macro arguments
25    0000 ~                    ENDLUA
26    0000 ~            .localMacroLabel:
27    0000 ~                    UNDEFINE __testM_arg1_tmp     ; release the global define
28    0000                  ENDM
29    0000
30    0000              x   = 88
31    0000              BigLabel1:
32    0000                  testM 0x1234
32    0000             >        ; convert macro-define "arg1?" to global define (makes it visible to Lua)
32    0000             >        DEFINE __testM_arg1_tmp arg1?
32    0000             >        LUA ALLPASS
32    0000 ~           >            x = sj.get_define("__testM_arg1_tmp")
32    0000 ~           >            _pl("!x = "..x)         -- DEFL type label "x" set to value x
32    0000 ~           >            _pc("ld de,arg1?")      -- _pc does the substitution
32    0000 ~           >            sj.add_word(x)          -- parsed value from lua variable
32    0000 ~           >            sj.add_word(_c("x"))    -- _c will at least recognize the inserted label
32    0000 ~           >            z = _c("arg1?")         -- now substitution in `_c` WORKS in v1.14.4
32    0000 ~           >            assert(x == sj.get_define("arg1?", true))   -- since v1.20.0 sj.get_define can also search macro arguments
32    0000             >!x = 0x1234
32    0000 11 34 12    >ld de,0x1234
32    0003 34 12 34 12 >        ENDLUA
32    0007             >.localMacroLabel:
32    0007             >        UNDEFINE __testM_arg1_tmp     ; release the global define
33    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   = 77
37    000B              BigLabel2:
38    000B                  testM 0x3456
38    000B             >        ; convert macro-define "arg1?" to global define (makes it visible to Lua)
38    000B             >        DEFINE __testM_arg1_tmp arg1?
38    000B             >        LUA ALLPASS
38    000B ~           >            x = sj.get_define("__testM_arg1_tmp")
38    000B ~           >            _pl("!x = "..x)         -- DEFL type label "x" set to value x
38    000B ~           >            _pc("ld de,arg1?")      -- _pc does the substitution
38    000B ~           >            sj.add_word(x)          -- parsed value from lua variable
38    000B ~           >            sj.add_word(_c("x"))    -- _c will at least recognize the inserted label
38    000B ~           >            z = _c("arg1?")         -- now substitution in `_c` WORKS in v1.14.4
38    000B ~           >            assert(x == sj.get_define("arg1?", true))   -- since v1.20.0 sj.get_define can also search macro arguments
38    000B             >!x = 0x3456
38    000B 11 56 34    >ld de,0x3456
38    000E 56 34 56 34 >        ENDLUA
38    0012             >.localMacroLabel:
38    0012             >        UNDEFINE __testM_arg1_tmp     ; release the global define
39    0012              .local2:
40    0012 56 34            DW  x
41    0014 18 FC            jr      BigLabel2.local2    ; same checks as above, but second value
42    0016
# file closed: lua_macro_arg.asm

Value    Label
------ - -----------------------------------------------------------
0x0007 X 0>localMacroLabel
0x0012 X 1>localMacroLabel
0x0000 X BigLabel1
0x0007   BigLabel1.local1
0x000B X BigLabel2
0x0012   BigLabel2.local2
0x3456   x