?login_element?

Subversion Repositories NedoOS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  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 still shows extra options of `sj.insert_label`, which are not shown in
  6.     ; official documentation. I'm not sure if these will stay for v2.x, so I'm
  7.     ; not adding them to docs, but you can learn about any hidden optional arguments
  8.     ; in sjasm/lua_sjasm.cpp file, tracking down the particular lua stub, and checking
  9.     ; how many arguments and types are parsed, and how they are used in the call
  10.     ; of internal sjasm function.
  11.     ; These are to stay in v1.x forever like this, unless there will be really serious
  12.     ; reason to modify them. For v2.x the main goal is to mostly keep them and make
  13.     ; them official, but som pruning/reorganization may happen, plus newer Lua version..
  14.  
  15.     MACRO testM arg1?
  16.         LUA ALLPASS
  17.             x = _c("arg1?")     -- get value of evaluated macro argument
  18.                 -- if you want the macro argument without evaluation
  19.                 -- check "lua_macro_arg.asm" test for DEFINE workaround
  20.             sj.insert_label("x", x, false, true)   -- isUndefined=false, isDefl=true
  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 sj.insert_label
  37.    jr      BigLabel1.local1    ; check "big" label was not modified by sj.insert_label
  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.