| Cray Assembly Language (CAL) for Cray X1TM Systems Reference Manual - S-2314-50 | ||
|---|---|---|
| Prev Section | Chapter 9. CAL Defined Sequences | Next Section |
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:
dupname
dupname specifies an optional name for the dup sequence. It is required if the count field is null or missing. If no count field is present, dupname must match an ENDDUP name. The sequence field in the DUP pseudo instruction itself represents the nested dup level and appears in columns 89 and 90 on the listing. For a description of sequence field nest level numbering, see Section 9.1.
The dupname variable must meet the requirements for names as described in Section 6.3.
expression
expression is an absolute expression with a positive value that specifies the number of times to repeat the code sequence. All symbols, if any, must be defined previously. If the current base is mixed, octal is used for the expression. If the value is 0, the code is skipped. You can use a STOPDUP to override the given expression.
The expression operand must meet the requirements for expressions as described in Section 6.9.
count
count is an optional absolute expression with positive value that specifies the number of statements to be duplicated. All symbols (if any) must be defined previously. If the current base is mixed, octal is used for the expression.
LOCAL pseudo instructions and comment statements (* in column 1) are ignored for the purpose of this count. Statements are counted before expansion of nested macro or opdef calls, and dup or echo sequences.
The count operand must meet the requirements for expressions as described in Section 6.9.
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 |
| Prev Section | Table of Contents | Title Page | Index | Next Section |
| Operation Definitions (OPDEF) | Up one level | Duplicate with Varying Argument (ECHO) |