?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  2. ;;; see listing file for resulting macro expansion
  3. ;;; in each example
  4.  
  5. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  6. ;;; Macro without parameters
  7.  
  8.   MACRO ADD_HL_A
  9.     ADD A,L
  10.     JR NC,.hup
  11.     INC H
  12. .hup
  13.     LD L,A
  14.   ENDM
  15.  
  16.   ADD_HL_A
  17.  
  18. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  19. ;;; A macro with parameters
  20.  
  21.   MACRO WAVEOUT reg, data
  22.     LD A,reg
  23.     OUT (7EH),A
  24.     LD A,data
  25.     OUT (7FH),A
  26.   ENDM
  27.  
  28.   WAVEOUT 2,17
  29.  
  30. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  31. ;;; Another example
  32.  
  33.     MACRO LOOP
  34.       IF $-.lus<127
  35.         DJNZ .lus
  36.       ELSE
  37.         DEC B
  38.         JP NZ,.lus
  39.       ENDIF
  40.     ENDM
  41.  
  42. Main
  43. .lus
  44.     CALL DoALot
  45.     LOOP
  46. DoALot:
  47.  
  48. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  49. ;;; Argument in angle brackets
  50.  
  51.     MACRO UseLess data
  52.       DB data
  53.     ENDM
  54.  
  55.     UseLess <10,12,13,0>
  56. ; use '!' to include '!' and '>' in those strings.
  57.     UseLess <5, 6 !> 3>
  58.     UseLess <"Kip!!",3>
  59.  
  60. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  61. ;;; Macro name at beginning of line
  62.  
  63. LabelAsMacroName    MACRO  arg1?, arg2?
  64.                         ld  a,arg1?
  65.                         ld  hl,arg2?
  66.                     ENDM
  67.  
  68.                 LabelAsMacroName 1,$1234
  69.  
  70. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  71. ;;; Inhibit macro expansion operator
  72.  
  73. djnz    MACRO   arg1?
  74.             dec c
  75.             jr  nz,arg1?
  76.             @djnz arg1? ; avoid self-reference and use real instruction
  77.         ENDM
  78.  
  79. 1:      djnz    1B      ; macro replacement will be used here
  80. 1:      @djnz   1B      ; original djnz instruction here
  81.