Crossware

Table of Contents        Previous topic       Next topic       

CROSS ASSEMBLER->Assembler Macros->Dummy Labels

If you include an ordinary label in the macro definition then, except where it is being defined using the SET directive, it will only be possible to call that macro once.  A second call will generate a duplicate label error.  Dummy labels overcome this problem.  Dummy labels are \.0 to \.9 and \.A to \.Z (or \.a to \.z since the dummy labels are case insensitive).  These symbols are used within the macro definition in place of ordinary labels, and when the macro is expanded the assembler replaces them with labels .00000, .00001, .00002 etc.  Unique labels are therefore generated each time the macro is called.  

The following example illustrates the use of dummy labels.

Firstly the source code listing:

       NAM     MACXAMPL
       TTL     *** Dummy Labels ***
       LIST
       SYM
       MEX
       ORG 6000H

; This is the macro definition:

macxampl MACR  
        MVI \0,60H
        MVI \1,52H
\.0      DCR \0
        JNZ \.0
        ENDM

; This is the macro call:
       
       macxampl A,B
 
And now the listing generated during assembly:

   1                            NAM       MACXAMPL
   2                            TTL       *** Dummy Labels ***
   3                            LIST
   4                            SYM
   5                            MEX
   6 6000                       ORG       6000H
   7
   8                  ; This is the macro definition:
   9
  10                  macxampl MACR
  11                           MVI \0,60H
  12                           MVI \1,52H
  13                  \.0      DCR \0
  14                           JNZ \.0
  15                           ENDM
  16
  17                  ; This is the macro call:
  18
  19                            macxampl  A,B
     6000 3E 60                 MVI       A,60H
     6002 06 52                 MVI       B,52H
     6004 3D          .00000    DCR       A
     6005 C2 04 60              JNZ       .00000
  20
  21
Assembly complete
Total bytes generated: 8
0 errors
0 warnings

Symbol table:

.00000   6004  
1 symbols.