| Cray Assembly Language (CAL) for Cray X1TM Systems Reference Manual - S-2314-50 | ||
|---|---|---|
| Prev Section | Chapter 6. CAL Source Statements | Next Section |
The result and operand fields for many source statements contain expressions. An expression consists of one or more constants (see Section 6.4), literals (see Section 6.6), location elements (see Section 6.8) or symbols (see Section 6.2) and zero or more operators (see Section 6.9.1).
There are some restrictions on the combinations of operands and operators that are allowed in the different contexts, as specified below.
The assembler will evaluate the expression, applying appropriate restrictions and if no restrictions are violated, insert the value of the expression into the immediate field in the machine instruction or the operand field of the pseudo instruction.
Registers are not included as part of a CAL expression. A register may be an operand in an instruction but the assembler cannot determine the value of the register. For example, in the instruction:
s5 s3+2*3 |
the assembler parses the instruction such that 2*3 is an expression that it evaluates and then inserts the value of 6 into the immediate field of the machine instruction. It does not treat s3 as part of the expression.
Each CAL expression has a type and a value. The type is one of:
absolute
object
function
If the type of the expression is either object or function, it has a relative attribute that is one of:
relocatable
external
immobile
and has an address attribute that is one of:
byte address
stack offset
The CAL operators are:
unary operators:
+ (unary plus)
- (unary minus)
~ (bitwise complement)
! (logical NOT)
B. (byte prefix)
b. (byte prefix)
W. (word prefix)
w. (word prefix)
L. (longword prefix)
l. (longword prefix)
< (mask right)
> (mask left)
binary operators:
+ (add)
- ( subtract)
* (multiply)
/ (divide)
& (bitwise AND)
| (bitwise OR)
^ (bitwise XOR)
&& (logical AND)
|| (logical OR)
<< (bitwise left shift)
>> (bitwise right shift)
CAL expressions are evaluated according to the following operator precedence:
! ~ +(unary) -(unary) B. W. L. b. w. l. < > Right to left * / Left to right + - Left to right << >> Left to right & Left to right ^ Left to right | Left to right && Left to right || Left to right |
Parentheses can be used to group an expression or subexpressions.
If the machine instruction has an immediate field (imm6, imm8, imm14, imm16, or imm20), then an expression is allowed in that subfield of the CAL instruction. If the value of the expression exceeds the size of the immediate field, the value will be truncated and a diagnostic message will be issued.
If a pseudo instruction has an expression field or subfield, the restrictions are described in Chapter 7. Only integer expressions are allowed in pseudo instructions unless explicitly stated otherwise.
If the expression includes one or more relocatable or external symbols that is known only at link time, the assembler will evaluate the expression including the symbol name and pass to the loader the symbol name and an offset value to allow the loader to complete the evaluation and insert the final value in the code of the executable.
A symbolic register designator may be an expression but may not include any relocatable symbols and the entire expression must be enclosed in parentheses.
Floating constants are allowed only in the CON pseudo instruction.
Two relocatable symbols can occur in the same expression only if the difference of the two symbols is taken.
| Prev Section | Table of Contents | Title Page | Index | Next Section |
| Location Elements | Up one level | Statement Editing |