Assembly Language Coding (ALC) Part 2
Assembly Language Coding (ALC) Part 2
Load Halfword
LH
R7,NEGBYTS
Reg 7 before: 00 00 00 C4
NEGBYTS before: FF F1
Reg 7 after: FF FF FF F1
NEGBYTS after: FF F1
69
ST
R7,FIELDA
Reg 7 before: 00 01 22 31
FIELDA before: 00 00 00 00
Reg 7 after: 00 01 22 31
FIELDA after: 00 01 22 31
70
STH
R5,FIELDB
Reg 5 before: 10 FF FF E4
FIELDB before: 00 00
Reg 5 after: 10 FF FF E4
FIELDB after: FF E4
71
72
73
74
Address constant literals allow for multiple literals of different types in one statement. e.g. MVC REPORT(6),=AL3(C'DAY',X'F3F1F0')
75
76
LM
R4,R7,INITFLDS
Reg 4 before: 00 00 00 00
Reg 4 after: 00 00 00 01
Reg 5 before: 00 88 12 FF
Reg 5 after: 00 00 00 02
Reg 6 before: 00 AB CD 00
Reg 6 after: 00 00 00 03
Reg 7 before: 00 FF 01 00
Reg 7 after: 00 00 00 04
77
Before: 00 00 00 00
After: 00 00 00 01
SAVEREGS
SAVEREGS
Before: 00 88 12 F0
After: 00 00 00 02
SAVEREGS+4
SAVEREGS+4
Before: F1 FE 82 17
After: 00 00 00 03
SAVEREGS+8
SAVEREGS+8
78
C1 C2 C3
CONST2 DC CONST2
CL3'NE'
D5 C5 40
CONST3 DC CONST3
CL3'ABCD'
C1 C2 C3
CONST4 DC CONST4
3C'5'
F5 F5 F5
CONST5 DC CONST5
2CL2'ABC'
C1 C2 C1 C2
79
APOSTR
DC APOSTR
C'''' 7D
AMPERS
DC AMPERS
C'&&' 50
ANB
DC ANB
C'A&&B' C1 50 C2
ASNBS
DC ASNBS
80
BINAR1
BINAR2
DC
BINAR2
BINAR3
DC
BINAR3
BINAR4
DC
BINAR4
81
HEX2 HEX2
DC
2X'B' 0B 0B
HEX3 HEX3
DC
XL2'ABCDE' BC DE
HEX4 HEX4
DC
2X'A1C2' A1 C2 A1 C2
HEX5 HEX5
DC
XL4'C12' 00 00 0C 12
82
The leftmost byte at the address specified in operand 2 is placed in the rightmost byte of the register specified in operand 1.
IC
R7,FIELDC
Reg 7 before: FF FF FF E4
FIELDC before: 11 22 33 44
Reg 7 after: FF FF FF 11
FIELDC after: 11 22 33 44
83
STC
R5,FIELDF+2
Before: 10
Reg 5
FF
FF
E4
F1
F2
C1 C2
FIELDF
After: 10
Reg 5
FF
FF
E4
F1
F2 E4 C2
FIELDF
84
The Insert Characters Under Mask copies N bytes (N <= 4) into a register. The number of bytes copied and their relative positions in the register are specified in the second operand of the instruction, the "mask". The number of bytes that are inserted is equal to the number of 1's in the mask. The relative position of the bytes in the register is determined by the relative position of 1's in the mask, left-to-right, one-to-one.
ICM
R4,B'1100',SAVE
Before
AB 01 8C 00
REG 4
09 FF E9 86
SAVE
After
09 FF 8C 00
REG 4
09 FF E9 86
SAVE
85
The Store Characters Under Mask copies N bytes (N <= 4) from a register into memory. The number of bytes copied and their relative positions in the register are specified in the second operand of the instruction, the "mask". The number of bytes that are stored is equal to the number of 1's in the mask. The relative position of the bytes in the register is determined by the relative position of 1's in the mask, left-to-right, one-to-one.
STCM
R4,X'A',SAVE
Before
01 23 AB CD
REG 4
E1 E2 E3 E4
SAVE
After
01 23 AB CD
REG 4
01 AB E3 E4
SAVE
86
EQ1 EQU INPUT EQ2 EQU INPUT+82 * NUMERIC TABLE STARTS HERE TABLE DC F'1' DC F'2' DC F'3' DC F'4' DC F'5' TBLEN EQU *-TABLE NMBRITMS EQU (*-TABLE)/4 (OR) NMBRITMS EQU TBLEN/4
87
MVI
The Move Immediate copies one byte of data from the I2 field to the location designated by the 1st operand. The I2 data is assembled into byte one of the instruction.
MVI D1(B1),I2
88
VAL1,C'*'
VAL1 before: A B C D E
VAL1 after: * B C D E
MVI
VAL1+3,C'*'
VAL1 before: * B C D E
VAL1 after: * B C * E
89
90
Name is first 15 positions starting @ position 1. Salary figures have no editing characters ($ , .). Report Header = GROSS PAY REPORT followed by a blank line. 2 spaces before PAY and DAILY.
91
92
93
94
The first operand always specifies a mask value. The second operand is a memory address to be branched to if the condition is met. e.g. BC
8,FOUND
BCR
M1,R2
As in the BC, the first operand of the BCR is always a mask value. The second operand is used quite differently however. The second operand is a register that must have been loaded with the branch-to address prior to executing the BCR. If the condition is met, branching will occur to the specified address in the R2 operand. Refer to the Enterprise Systems Architecture/390 Reference Summary for condition codes and their corresponding mask values.
95
This code checks for CC = 2 (0010) and branches to the address in register 7 if the condition is true.
A BC BC
This code checks for condition of zero or negative and branches accordingly. Positive condition results in fall-thru.
C BC
R1,FLDA 12,ALOEQ
This code checks for 2 settings at once - low and equal, and branches accordingly.
96
(Fact be know, you could not get the code above to run on the TPF system because of Protect Keys.)
97
R1,R3,D2(B2)
Branch address
Increment Register
When a BXLE instruction is executed, three things occur during the iteration of the loop: 1. Incrementing the index register. 2. Counting the number of iterations of the loop. 3. Testing to see whether the loop should be repeated. An increment is added to the first operand and the sum is compared with a comparand (the limit register). Subsequently, the sum is placed in the first operand location. When the sum is low or equal, the instruction address in the current PSW is replaced by the branch address (the second operand is used as the branch address). The first operand and the increment are in the registers specified by R1 and R3. The comparand register number is odd and is either one larger than R3 or equal to R3. The branch address is computed before the addition and comparison.
98
MORE
Using 2 Registers
LM EQU L A ST BXLE . DS DS DS R4,R5,=F'-12,4' * R0,TABA+12(R4) R0,TABB+12(R4) R0,TABC+12(R4) R4,R5,MORE 5F 5F 5F R4 = Index Reg. R5 = Incr. & Limit
MORE
99
MORE *
5F 5F 5F
100
The second operand is placed unchanged in the first operand location, and the sign and magnitude of the second operand is used to determine and set the condition code (refer to the Principles of Operation for more details).
Condition code settings: 0 - the result is zero 1 - the result is less than zero 2 - the result is greater than zero 3 - not used
LTR
R4,R2
Reg 4 before: 00 81 34 77
Reg 2 before: 00 00 12 11
Reg 4 after: 00 00 12 11
Reg 2 after: 00 00 12 11
In this case, the condition code is set to 2. Note: when the R1 and R2 fields designate the same register the operation is simply a test with no data movement.
101
The twos complement of the absolute value of the second operand is placed in the first operand location. Negative numbers remain unchanged. Zero remains unchanged.
LNR
R4,R2
Reg 4 before: 00 81 34 77
Reg 2 before: 00 00 12 11
Reg 4 after: FF FF ED EF
Reg 2 after: 00 00 12 11
102
The absolute value of the second operand is placed in the first operand location. Positive numbers remain unchanged. Zero remains unchanged.
LPR
R4,R2
Reg 4 before: 00 00 00 00
Reg 2 before: FF FF AB AB
Reg 4 after: 00 00 54 55
Reg 2 after: FF FF AB AB
103
The twos complement of the second operand is placed in the first operand location. Zero remains unchanged.
LCR
R4,R2
Reg 4 before: 00 00 00 04
Reg 2 before: 00 00 54 55
Reg 4 after: FF FF AB AB
Reg 2 after: 00 00 54 55
104
105
CR
R3,R4
00
REG 3
00
00
0A
00
REG 4
00
00
C8
CC = 1
CR
R4,R5
00
REG 4
00
00
C8
FF
REG 5
FF
FF
FF
CC = 2
106
R3,STORAGE
00
REG 3
80
59
34
00
00
FF
F9
STORAGE
CC = ?
107
R3,AMT1 R3,AMT2
CC = ?
108
Name is first 15 positions starting @ position 1. Salary figures have no editing characters ($ , .). Report Header = GROSS PAY REPORT centered. and followed by blank line. 2 spaces before PAY and OVERTIME.
109
110
111
CL R3,SAVE
00
SAVE
00
00
01
FF
REG 3
FF
FF
FE
CC = 2
112
CLR R3,R4
00
REG 3
00
C1
C2
00
REG 4
00 D1 D2
CC = 1
113
The Compare Logical Characters Under Mask compares two N-byte strings (N <= 4), the first string is in the register designated by the first operand. The second string is in the memory location designated by the second operand.
CLM
R5,B'0001',=X'00'
00 C3 FF D5
REG 5
00
Memory
CC = 2
114
115
C4
FIELD
C2
C6
C4
CC CC CC CC
= = = =
0 1 2 0
116
DC DC DC
117
General Rules: 1. All shift instructions have an RS format. 2. The 2nd operand address is not used to address data. Instead, the low order 6 bits of the address computed are used to determine the shift value (number of bits to be shifted). 3. Bits 12-15 of the object code are not used. Algebraic shifts: 1. First operand is treated as a 31 or 63 bit integer. 2. The sign bit will not change. 3. The condition code is set after execution. Logical shifts: 1. First operand is treated as a 32 or 64 bit integer. 2. The sign bit can change, no inspection is made. 3. The condition code is not affected by the instruction.
118
SLA
R5,8(R0)
Before 00 7F 0A 72
REG 5
After 7F 0A 72 00
REG 5
119
SRA
R5,0(R4)
Before 80 64 E6 00
REG 5
00 00 00 0C
REG 4
After FF F8 06 4E
REG 5
00 00 00 0C
REG 4
120
SLDA R4,8(R6)
Before
00 00 B6 E8
REG 4
BE E8 01 00
REG 5
00 00 00 08
REG 6
After
36 E8 BE E8
REG 4
01 00 00 00
REG 5
00 00 00 08
REG 6
The 63 numeric bits of the even-odd register pair are shifted to the left, leaving the sign bit unchanged. Because a significant bit is shifted out of bit position 1 of register 4, overflow is indicated by setting condition code to 3.
121
SRDA R4,4(R6)
Before
80 00 C8 B4
REG 4
FF FF FF FF
REG 5
00 00 00 08
REG 6
After
FF F8 00 0C
REG 4
8B 4F FF FF
REG 5
00 00 00 08
REG 6
122
SLL R5,8(R4)
Before 00 00 0A BC
REG 5
00 00 00 04
REG 4
After 00 AB C0 00
REG 5
00 00 00 04
REG 4
123
SRL R5,8(R4)
Before 00 AB C0 00
REG 5
00 00 00 04
REG 4
After 00 00 0A BC
REG 5
00 00 00 04
REG 4
124
SLDL R4,8(R6)
Before
00 00 B6 E8
REG 4
BE E8 01 00
REG 5
00 00 00 08
REG 6
After
B6 E8 BE E8
REG 4
01 00 00 00
REG 5
00 00 00 08
REG 6
125
SRDL R4,4(R6)
Before
80 00 C8 B4
REG 4
FF FF FF FF
REG 5
00 00 00 08
REG 6
After
00 08 00 0C
REG 4
8B 4F FF FF
REG 5
00 00 00 08
REG 6
126
After compare instructions (A:B) BH BL BE BNH BNL BNE or or or or or or BHR BLR BER BNHR BNLR BNER Branch on A High Branch on A Low Branch on A Equal B Branch on A Not High Branch on A Not Low Branch on A Not Equal B
127
After the TM (Test Under Mask) instruction BO BZ BM BNO BNZ BNM or or or or or or BOR BZR BMR BNOR BNZR BNMR Branch if Ones Branch if Zeros Branch if Mixed Branch if Not Ones Branch if Not Zeros Branch if Not Mixed
128
LOC OBJECT CODE 000485 C4C1E8 CL3'DAY' 000488 D4E2D7 CL3'MSP' 00048B 00 00048C 00000485
454
ADDRESS DC A(LIT2)
129
label
DC
V(PROG2)
STMT SOURCE STATEMENT DC CL3'DAY' DC CL3'MSP' DC A(LIT2)
ADDR1 ADDR2
130