?login_element?

Subversion Repositories NedoOS

Rev

Rev 126 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download

  1.     ORG 'PS'  :   OUTPUT "Issue45B_arg_substitution.bin"
  2.  
  3.     ; labels expected to emerge from the macro argument substition
  4. TESTD_mydef_TESTD_12345:
  5. mydef_TESTD_12345:
  6.  
  7.     MACRO def name?, val?
  8.         ld  sp,name?_mydef_name?_val?
  9.         ld  sp,mydef_name?_val?
  10.     ENDM
  11.  
  12.     def TESTD, 12345
  13.  
  14.     DEFINE MY_VERSION "1.2.3.4.5"   ; should not clash with sjasmplus _VERSION define
  15.     db "\nMy version: ", MY_VERSION, ", sjasm: ", '0'+_SJASMPLUS, "\n"
  16.     DISPLAY "Sjasmplus version: ", _VERSION
  17.  
  18.     ; as result of the refactoring happening due to Issue #45 and #35, now array indexing by array should work
  19.  
  20.     DEFARRAY arrayIdx 2,3,4,0,1
  21.     DEFARRAY arrayTxt 't0', 't1', 't2', 't3', 't4'
  22.  
  23.     ; simple hard-wired source to access array elements
  24.     db  "\n", arrayTxt[0], " ", arrayTxt[1], " ", arrayTxt[2], " ", arrayTxt[3], " ", arrayTxt[4], "\n"
  25.  
  26.     ; dynamic array access in DUP repeater
  27. ii=0
  28.     DUP 4
  29.         db  arrayTxt[ii], " "
  30. ii=ii+1
  31.     EDUP
  32.     db  arrayTxt[4], "\n"
  33.  
  34.     ; hard-wired source to access array elements with extra indirection
  35.     db  arrayTxt[arrayIdx[0]], " ", arrayTxt[arrayIdx[1]], " ", arrayTxt[arrayIdx[2]], " ", arrayTxt[arrayIdx[3]], " "
  36.     db  arrayTxt[arrayIdx[4]], "\n"
  37.  
  38.     ; dynamic indirect array access in DUP repeater
  39. ii=0
  40.     DUP 4
  41.         db  arrayTxt[arrayIdx[ii]], " "
  42. ii=ii+1
  43.     EDUP
  44.     db  arrayTxt[arrayIdx[4]], "\n"
  45.  
  46.     END
  47.  
  48.     ;;FIXME not working. Maybe because the [ARRAY] handler is trying to evaluate
  49.     ; the index-expression too aggressively and too early, not giving the macro
  50.     ; substitution enough time to replace `idx?` with actual value?
  51.  
  52.     ; read array items in macro
  53.     MACRO readArray idx?
  54. .ii=-idx?
  55.         db      arrayTxt[ arrayIdx[ idx? + .ii ] ], " "
  56.         db      arrayTxt[ arrayIdx[ .ii + idx? ] ], " "
  57.         DUP idx?
  58.             DEFINE readArrayM_idx? .ii+idx?
  59.             db      arrayTxt[ arrayIdx[ .ii + idx? ] ], " "
  60.             db      arrayTxt[arrayIdx[readArrayM_idx?]], " "
  61.             IF 0 <= readArrayM_idx?
  62.                 db      arrayTxt[arrayIdx[readArrayM_idx?]], " "
  63.             ENDIF
  64.             UNDEFINE readArrayM_idx?
  65. .ii=.ii+1
  66.         EDUP
  67.     ENDM
  68.  
  69.     readArray 4
  70.     db  arrayTxt[arrayIdx[4]], "\n"
  71.