HLASM Language Reference

HLASM Language Reference HLASM Language Reference

faculty.cs.niu.edu
from faculty.cs.niu.edu More from this publisher
22.02.2015 Views

SETA Instruction In evaluating the arithmetic expression in the fifth statement, the first term, &C(1), is assigned the binary value 11 (decimal 5). To that is added the value represented by the EBCDIC character A (hexadecimal C1, which corresponds to decimal 193). Then the value represented by the third term &C(3) is subtracted, and the value of &A becomes 5+193−23=175. This feature lets you associate numeric values with EBCDIC or hexadecimal characters to be used in such applications as indexing, code conversion, translation, and sorting. Assume that &X is a character string with the value ABC. &I SETC 'C'''.'&X'(1,1).'''' &VAL SETA &TRANS(&I) The first statement sets &I to C'A'. The second statement extracts the 193rd element of &TRANS (C'A' = X'C1' = 193). The following code converts a hexadecimal value in &H into a decimal value in &VAL: &X SETC 'X''&H''' &VAL SETA &X The following code converts the double-byte character Da into a decimal value in &VAL. &VAL can then be used to find an alternative code in a subscripted SETC variable: &DA SETC 'G''''' &VAL SETA &DA Although you can use a predefined absolute symbol as an operand in a SETA expression, you cannot substitute a SETC variable whose value is the same as the symbol. For example: ABS EQU 5 &ABS SETA ABS &ABS has value 5 &CABS SETC 'ABS' &CABS has value 'ABS' &ABS SETA &CABS invalid usage DBCS Assembler Option: The G-type self-defining term is valid only if the DBCS assembler option is specified. Using SETA symbols The arithmetic value assigned to a SETA symbol is substituted for the SETA symbol when it is used in an arithmetic expression. If the SETA symbol is not used in an arithmetic expression, the arithmetic value is converted to a character string containing its absolute value, with leading zeros removed. If the value is 0, it is converted to a single 0. Example: 360 HLASM V1R5 Language Reference

SETA Instruction MACRO &NAME MOVE &TO,&FROM LCLA &A,&B,&C,&D &A SETA 1 Statement 1 &B SETA 12 Statement 2 &C SETA &A–&B Statement 3 &D SETA &A+&C Statement 4 &NAME ST 2,SAVEAREA L 2,&FROM&C Statement 5 ST 2,&TO&D Statement 6 L 2,SAVEAREA MEND ------------------------------------------------------------------- HERE MOVE FIELDA,FIELDB ------------------------------------------------------------------- +HERE ST 2,SAVEAREA + L 2,FIELDB2 + ST 2,FIELDA8 + L 2,SAVEAREA Statements 1 and 2 assign the arithmetic values +1 and +12, respectively, to the SETA symbols &A and &B. Therefore, statement 3 assigns the SETA symbol &C the arithmetic value −2. When &C is used in statement 5, the arithmetic value −2 is converted to the character 2. When &C is used in statement 4, however, the arithmetic value −2 is used. Therefore, &D is assigned the arithmetic value +8. When &D is used in statement 6, the arithmetic value +8 is converted to the character 8. The following example shows how the value assigned to a SETA symbol may be changed in a macro definition. MACRO &NAME MOVE &TO,&FROM LCLA &A &A SETA 5 Statement 1 &NAME ST 2,SAVEAREA L 2,&FROM&A Statement 2 &A SETA 8 Statement 3 ST 2,&TO&A Statement 4 L 2,SAVEAREA MEND ------------------------------------------------------------------- HERE MOVE FIELDA,FIELDB ------------------------------------------------------------------- +HERE ST 2,SAVEAREA + L 2,FIELDB5 + ST 2,FIELDA8 + L 2,SAVEAREA Statement 1 assigns the arithmetic value +5 to SETA symbol &A. In statement 2, &A is converted to the character 5. Statement 3 assigns the arithmetic value +8 to &A. In statement 4, therefore, &A is converted to the character 8, instead of 5. A SETA symbol may be used with a symbolic parameter to refer to an operand in an operand sublist. If a SETA symbol is used for this purpose, it must have been assigned a positive value. Chapter 9. How to Write Conditional Assembly Instructions 361

SETA Instruction<br />

MACRO<br />

&NAME MOVE &TO,&FROM<br />

LCLA<br />

&A,&B,&C,&D<br />

&A SETA 1 Statement 1<br />

&B SETA 12 Statement 2<br />

&C SETA &A–&B Statement 3<br />

&D SETA &A+&C Statement 4<br />

&NAME ST 2,SAVEAREA<br />

L 2,&FROM&C Statement 5<br />

ST 2,&TO&D Statement 6<br />

L<br />

2,SAVEAREA<br />

MEND<br />

-------------------------------------------------------------------<br />

HERE MOVE FIELDA,FIELDB<br />

-------------------------------------------------------------------<br />

+HERE ST<br />

2,SAVEAREA<br />

+ L 2,FIELDB2<br />

+ ST 2,FIELDA8<br />

+ L 2,SAVEAREA<br />

Statements 1 and 2 assign the arithmetic values +1 and +12, respectively, to the<br />

SETA symbols &A and &B. Therefore, statement 3 assigns the SETA symbol &C<br />

the arithmetic value −2. When &C is used in statement 5, the arithmetic value −2 is<br />

converted to the character 2. When &C is used in statement 4, however, the<br />

arithmetic value −2 is used. Therefore, &D is assigned the arithmetic value +8.<br />

When &D is used in statement 6, the arithmetic value +8 is converted to the<br />

character 8.<br />

The following example shows how the value assigned to a SETA symbol may be<br />

changed in a macro definition.<br />

MACRO<br />

&NAME MOVE &TO,&FROM<br />

LCLA<br />

&A<br />

&A SETA 5 Statement 1<br />

&NAME ST 2,SAVEAREA<br />

L 2,&FROM&A Statement 2<br />

&A SETA 8 Statement 3<br />

ST 2,&TO&A Statement 4<br />

L<br />

2,SAVEAREA<br />

MEND<br />

-------------------------------------------------------------------<br />

HERE MOVE FIELDA,FIELDB<br />

-------------------------------------------------------------------<br />

+HERE ST<br />

2,SAVEAREA<br />

+ L 2,FIELDB5<br />

+ ST 2,FIELDA8<br />

+ L 2,SAVEAREA<br />

Statement 1 assigns the arithmetic value +5 to SETA symbol &A. In statement 2, &A<br />

is converted to the character 5. Statement 3 assigns the arithmetic value +8 to &A.<br />

In statement 4, therefore, &A is converted to the character 8, instead of 5.<br />

A SETA symbol may be used with a symbolic parameter to refer to an operand in<br />

an operand sublist. If a SETA symbol is used for this purpose, it must have been<br />

assigned a positive value.<br />

Chapter 9. How to Write Conditional Assembly Instructions 361

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!