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 DEFL 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  
        LD \0,$60
        LD \1,$52
\.0      ADD \0,\1
        JR NZ,\.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                             LD \0,$60
  12                             LD \1,$52
  13                    \.0      ADD \0,\1
  14                             JR NZ,\.0
  15                             ENDM
  16
  17                    * This is the macro call:
  18
  19                              macxampl A,B         
     6000 3E 60                   LD      A,$60       
     6002 06 52                   LD      B,$52       
     6004 80            .00000    ADD     A,B         
     6005 20 FD                   JR      NZ,.00000   
  20
  21
Assembly complete
Bytes filed: 7
0 errors
0 warnings

Symbol table:

.00000   6004  
1 symbols.