?login_element?

Subversion Repositories NedoOS

Rev

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

  1.     ; test the new way of lua `_c`/`sj.calc` function to do the define/macro_arg
  2.     ; substitution before the expression is evaluated, so using macro arguments
  3.     ; inside lua script should be now trivial, no more workaround through DEFINE.
  4.  
  5.     ; this example has been reworked to conform to updated lua5.4 and only official
  6.     ; documented Lua bindings, the `sj.insert_label` has no more the optional arguments
  7.     ; that said, you can use instead the regular asm syntax and `_pl` binding to create
  8.     ; any kind of special flavour of label (DEFL, EQU, global, local, ...)
  9.  
  10.     ; The extra options of `sj.insert_label` were promised to stay in v1.x
  11.     ; in the original test code, unless there is serious reason. Upgrade
  12.     ; to lua 5.4 is actually *that* serious reason, sorry.
  13.  
  14.     ; OBSOLETE by v1.20.0: now sj.get_define get search also macro arguments
  15.     MACRO testM arg1?
  16.         LUA ALLPASS
  17.             x = _c("arg1?")     -- get value of evaluated macro argument
  18.             -- if you want macro argument without evaluation or string value, use sj.get_define
  19.             assert(x == 0+sj.get_define("arg1?", true)) -- enabling macro-arg search with second option
  20.             _pl("!x = "..x)         -- DEFL type label "x" set to value x
  21.             _pc("dw arg1?, x, "..x) -- check all three sources of input value
  22.                 -- _pc does it's own substitution, the label "x" should be set and lua "x"
  23.            -- test _c a bit more for handling weird things...
  24.            e1 = _c("/* ehm")
  25.            e2 = _c("define arg1? xx")  -- will emit error "Label not found: define" = OK
  26.            e3 = _c("$FF&".._c("arg1?"))
  27.            _pc("db /* e1, e2, e3 */ "..e1..","..e2..","..e3)
  28.        ENDLUA
  29. .localMacroLabel:   ; check which root the macro local label gets (should be per emit)
  30.    ENDM
  31.  
  32. x   = 88
  33. BigLabel1:
  34.    testM 0x1234
  35. .local1:
  36.    DW  x                       ; check that symbol "x" was set by _pl("!x = "..x)
  37.    jr      BigLabel1.local1    ; check "big" label was not modified by _pl("!x = "..x)
  38. x   = 77
  39. BigLabel2:
  40.    testM 0x3456
  41. .local2:
  42.    DW  x
  43.    jr      BigLabel2.local2    ; same checks as above, but second value
  44.