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
 ORG 6000H

* This is the macro definition:

macxampl MACR  
        MOVE $6000,\0
        MOVE $52,\1
\.0      ADD \1,\0
        DBEQ \0,\.0
        ENDM

* This is the macro call:

macxampl D1,D2

And now the listing generated during assembly:

   1                                         NAM     MACXAMPL
   2                                         TTL     *** Dummy
                                                     Labels ***
   3                                         LIST                    4 00000000                                SYM                     5
00006000                                ORG     6000H           6
   7                               * This is the macro
                                     definition:
   8
   9                               macxampl MACR  
  10                                        MOVE $6000,\0
  11                                        MOVE $52,\1
  12                               \.0      ADD \1,\0
  13                                        DBEQ \0,\.0
  14                                        ENDM
  15
  16                               * This is the macro call:
  17
  18                                         macxampl D1,D2
     00006000 32386000                       MOVE    $6000,D1
     00006004 34380052                       MOVE    $52,D2
     00006008 D242                 .00000    ADD     D2,D1     
     0000600A 57C9FFFC                       DBEQ    D1,.00000
  19
Assembly complete
Bytes filed: 14
0 errors
0 warnings

Symbol table:

.00000   00006008  
1 symbols.