?login_element?

Subversion Repositories NedoOS

Rev

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

  1.     ; OBSOLETE, define/macro_arg substitution is added to `_c`/`sj.calc` in v1.14.4
  2.     ; check new test lua_macro_arg2.asm
  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 sj.insert_label, and it's extra undocumented optional arguments to keep
  9.     ;   that global symbol of "DEFL" type (like "=" in asm source), so it can be
  10.     ;   redefined over and over with new values
  11.     ; Also macro arguments are substituted inside Lua `_pl()` and `_pc()` (parse line,
  12.     ;   parse code), but not 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.             sj.insert_label("x", x, false, true)   -- isUndefined=false, isDefl=true
  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?")         -- does NOT work. Should it?
  24.                 -- now substitution in `_c` WORKS in v1.14.4
  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 sj.insert_label
  35.     jr      BigLabel1.local1    ; check "big" label was not modified by sj.insert_label
  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.