9.4. Duplication (DUP)

The DUP pseudo instruction defines a sequence of code that is assembled repetitively immediately following the definition. The sequence of code is assembled the number of times specified on the DUP pseudo instruction. The sequence of code to be repeated consists of the statements following the DUP pseudo instruction and any optional LOCAL pseudo instructions. Comment statements are ignored. The sequence to be duplicated ends when the statement count is exhausted or when an ENDDUP pseudo instruction with a matching label field name is encountered.

The DUP pseudo instruction only accepts one type of formal parameter. That parameter must be specified with the LOCAL pseudo instruction.

You can specify the DUP pseudo instruction anywhere within a program segment. If the DUP pseudo instruction is found within a definition, it is defined and is not recognized as a pseudo instruction. If the DUP pseudo instruction is found within a skipping sequence, it is skipped and is not recognized as a pseudo instruction.

The format of the DUP pseudo instruction is as follows:

[dupname]     DUP     expression[,[count]]

The variables associated with the DUP pseudo instruction are described as follows:

In the following example, the code sequence following the DUP pseudo instruction will be repeated 3 times. There are 5 statements in the sequence.

       DUP    3,5
       LOCAL   SYM1,SYM2       ; LOCAL pseudo instruction not counted.
*Asterisk comment; not counted
       S1      1               ; First statement is definition.
*Asterisk comment; not counted
       INCLUDE  ALPHA          ; INCLUDE pseudo instruction not
                               ; counted. 

The following is the file, ALPHA:

     S2   3               ; Second statement in definition.
     S4    4              ; Third statement in definition.
*Asterisk comment         ; not counted
     S5    5              ; Fourth statement in definition.
     S6    6              ; Fifth statement in definition. 

In the following example, the two con pseudo instructions are duplicated three times immediately following the definition:

         list      dup
example  dup       3        ; Definition.
         con       1
         con       2
example  enddup    

The following example illustrates the expansion of the preceding example:

     con   1
     con   2
     con   1 
     con   2
     con   1
     con   2