The concatenation expression forms a primary from selected parts of two or more primaries.
<concatenation expression>
──┬─<arithmetic concatenation expression>─┬────────────────────────────┤ └─<Boolean concatenation expression>────┘
<arithmetic concatenation expression>
──<arithmetic primary>── & ──<arithmetic expression>──<concatenation>──┤
<Boolean concatenation expression>
──<Boolean primary>── & ──<Boolean expression>──<concatenation>────────┤
A concatenation expression is formed by taking a specified part of the bit pattern of an expression value and copying it into the specified portion of a primary. The rest of the destination primary is not changed by this operation.
Note that only arithmetic expressions can be concatenated with arithmetic primaries, and only Boolean expressions can be concatenated with Boolean primaries.
Because the concatenation expression is a primary and the syntax for a concatenation expression is of the form <primary> & <expression> <concatenation>, concatenation expressions of the following form are allowed:
<primary> & <expression> <concatenation>
& <expression> <concatenation>
.
.
.
& <expression> <concatenation>If more than one concatenation term is used in a concatenation expression, as in the preceding example, then these terms are evaluated from left to right.
Concatenation
<concatenation>
── [ ──<left bit to>── : ─┬──────────────────────┬─<number of bits>────►
└─<left bit from>── : ─┘
►─ ] ──────────────────────────────────────────────────────────────────┤
<left bit to>
──<arithmetic expression>──────────────────────────────────────────────┤
<left bit from>
──<arithmetic expression>──────────────────────────────────────────────┤
<number of bits>
──<arithmetic expression>──────────────────────────────────────────────┤
The concatenation construct describes the location in the expression of the field to be copied and the location in the destination primary where the field is to be copied.
The <left bit to> element defines the leftmost bit location of the field in the destination word. The <left bit from> element defines the leftmost bit location of the field in the source word. The <number of bits> element specifies the length of the field to be copied from the source to the destination.
If the [<left bit to>:<left bit from>:<number of bits>] form is used, the field of bits to be copied starts at <left bit from> in the source word and is <number of bits> long.
If the [<left bit to>:<number of bits>] form is used, then the field of bits to be copied from the source word starts at bit number (<number of bits>–1) and extends through bit 0. That is, the source field is assumed to be the low-order <number of bits> bits in the source word.
The values of the <left bit to> and <left bit from> elements must lie within the range 0 through 47, where bit 0 is the rightmost, or least significant, bit in the word.
The value of the number of bits must lie within the range 1 through 48. If the value of the number of bits exceeds the number of bits to the right of the starting bit in either the source or destination words, these fields wrap around and are continued at bit 47, the leftmost bit, of the same word.
If, through the use of variables, the ranges for the <left bit to>, <left bit from>, or <number of bits> elements are exceeded, then the program is discontinued with a fault. If 0 is used as the number of bits, no bits are copied.
Because a concatenation expression is a primary, when it appears as an operand in a larger expression, the concatenation expression is evaluated before any other operation is executed. The following is an example of a concatenation expression evaluation:
|
Expression |
Evaluated as |
|
2**4 & 1 [0:0:1] |
2**(4 & 1 [0:0:1]) = 2**5 = 32 |
The expression is not evaluated as the following:
(2**4) & 1 [0:0:1] = 16 & 1 [0:0:1] = 17
Examples of Concatenation Expressions
Assume that the real variables X, Y, and Z have the following values:
X = 32767 = 4"000000007FFF" Y = 1024 = 4"000000000400" Z = 1 = 4"000000000001"
Given these values, the following are examples of arithmetic concatenation expressions and their values:
|
Expression |
Value |
|
X & Y [47:11:4] |
4"400000007FFF" |
|
X & Y [47:12] |
4"400000007FFF" |
|
Y & X [39:20] |
4"0007FFF00400" |
|
Y & Z [46:1] |
4"400000000400" |
|
0 & Y [11:11] |
4"000000000800" |
|
0 & X [23:48] |
4"007FFF000000" |
|
X & Y [39:12] & Z [47:1] |
4"804000007FFF" |
|
Y & X [19:15:8] |
4"00000007F400" |
Assume that the elements of the real array INFO contain information about the data in a file. Each element of INFO contains a record number in the field [19:20], and the length of the data in that record is in field [39:20]. That is, each element of INFO stores the location and length of a record in the data file. Let N be a variable that contains a record number, and let L be a variable that contains the length of that record.
The following declarations and assignment statement can be used to store a value into an element of INFO:
DEFINE
REC_NUMF = [19:20]#,
LENGTHF = [39:20]#;
.
.
.
INFO[I]:= 0 & N REC_NUMF
& L LENGTHF;
