?login_element?

Subversion Repositories NedoOS

Rev

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

  1.     ; OBSOLETE *more*, v1.20.0: sj.get_define is now extended to search also macro arguments
  2.     ; OBSOLETE, define/macro_arg substitution is added to `_c`/`sj.calc` in v1.14.4
  3.  
  4.     ; this test shows possible workaround for:
  5.     ; 1) extracting macro arg through regular DEFINE (to not tamper with current
  6.     ;   "big" label from outside the macro, otherwise one can also set global label)
  7.     ; 2) how to store intermediate values into global labels from inside Lua script
  8.     ;   with _pl creating full asm line with non-main DEFL type of label, so it can
  9.     ;   be redefined over and over with new values (the sj.insert_label does produce
  10.     ;   only regular labels, which can't change value multiple times.
  11.     ; Also macro arguments are substituted inside Lua `_pl()` and `_pc()` (parse line,
  12.     ;   parse code), and inside `_c` (calculate expression)
  13.  
  14.     MACRO testM arg1?
  15.         ; convert macro-define "arg1?" to global define (makes it visible to Lua)
  16.         DEFINE __testM_arg1_tmp arg1?
  17.         LUA ALLPASS
  18.             x = sj.get_define("__testM_arg1_tmp")
  19.             _pl("!x = "..x)         -- DEFL type label "x" set to value x
  20.             _pc("ld de,arg1?")      -- _pc does the substitution
  21.             sj.add_word(x)          -- parsed value from lua variable
  22.             sj.add_word(_c("x"))    -- _c will at least recognize the inserted label
  23.             z = _c("arg1?")         -- now substitution in `_c` WORKS in v1.14.4
  24.             assert(x == sj.get_define("arg1?", true))   -- since v1.20.0 sj.get_define can also search macro arguments
  25.         ENDLUA
  26. .localMacroLabel:
  27.         UNDEFINE __testM_arg1_tmp     ; release the global define
  28.     ENDM
  29.  
  30. x   = 88
  31. BigLabel1:
  32.     testM 0x1234
  33. .local1:
  34.     DW  x                       ; check that symbol "x" was set by _pl("!x = "..x)
  35.     jr      BigLabel1.local1    ; check "big" label was not modified by _pl("!x = "..x)
  36. x   = 77
  37. BigLabel2:
  38.     testM 0x3456
  39. .local2:
  40.     DW  x
  41.     jr      BigLabel2.local2    ; same checks as above, but second value
  42.