IBM Assembly Language Coding (ALC) Part 1
IBM Assembly Language Coding (ALC) Part 1
Main Storage
Main storage (memory) is measured in terms of 8-bit bytes and an address is assigned to each. The first byte is assigned address zero, the second byte address one, etc. Main storage is directly addressable and provides for high-speed processing of data. Both data and programs must be loaded into main storage from input devices before they can be processed. The amount of main storage available depends on the model of the CPU. Mainframes today (1998) can have up to 2 Gigabytes of real memory. Worldspan has mainframes with 2 Gigabytes of real memory. This means that byte addresses on such a computer run from 0 to 2,097,143,807 (7CFFDFFF in hex).
18 19
32 33
Instruction Address
63
Condition Code
Address Mode
Condition Code (CC): Bits 18 and 19 are used to contain the condition code. The condition code is set to 0, 1, 2 or 3, depending on the result obtained in executing most arithmetic and logical operations as well as some other operations. Addressing Mode: Bit 32 controls the size of effective address generation. When the bit is zero, 24-bit addressing is specified. When the bit is one, 31-bit addressing is specified. Instruction Address: Bits 33 - 63 form the instruction address. This address designates the location of the leftmost byte of the next instruction to be executed.
3
R6,CE1CR0
CE1CR0 before: 00 F2 CE 83
CE1CR0 after: 00 F2 CE 83
Reg 6 before: 00 00 10 0C
Reg 6 after: 00 F2 CE 83
The Move Characters instruction actually copy data from one memory location to another. MVC The Move Character copies L bytes (where L <= 256) from the memory location designated by the 2nd operand to the memory location designated by the 1st operand. The result is a byte-for-byte move.
MVC MVC MVC MVC D1(L,B1),D2(B2) 10(17,R3),0(R4) LABEL1,LABEL2 10(17,R3),LABEL2
10
VAL1 VAL2
DC DC
C'ABCDE' C'1*!?2'
VAL2 after: A B C D E
11
DC DC DC DC
RESULT,VAL1
RESULT before: b b b b b b b b
RESULT after: A B C D X Y G A
MVC
RESULT(4),VAL1
RESULT before: b b b b b b b b
RESULT after: A B C D b b
12
DC DC DC DC
RESULT+4,VAL2
before: b b b b b b b b A B C D X Y
RESULT
VAL1
VAL2
after: b b b b X Y G A R B A G X Y
RESULT
VAL1
VAL2
13
B1 DC OUTPUT DS MVC
OUTPUT,OUTPUT-1
before: b ? ? ? ? ? ? ? ? .....
B1 OUTPUT
after: b b b b b b b b b .....
B1 OUTPUT
14
DC DC DC DC
RESULT+4(2),VAL2
before: b b b b b b b b A B C D
RESULT
VAL1
after: b b b b X Y b b A B C D
RESULT
VAL1
15
16
Workarea ..
1/A
.....
Workarea ..
2/B
17
18
20
32 33
40
24-bit address 31-bit address
63
Address Mode Bit: Off (0) = 24-bit addressing On (1) = 31-bit addressing
21
23
24
25
+ +
+ +
Binary Contains two digits 0 and 1 with a base power of two. The value of the binary number 10101 is computed as:
1 1 x 24 16 + + 0 0 x 23 0 + + 1 1 x 22 4 0 + 0 x 21 + 0 + + 1 1 x 20 1 = 2110
26
27
Binary
0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 10000
Hexadecimal
0 1 2 3 4 5 6 7 8 9 A B C D E F 10
28
Subtraction is also straight forward, since the only situation in which a borrow operation can arise is that of subtracting 1 from 0. A borrow of 1 is necessary when the first digit is smaller than the second. Examples: 10110 101 ----------10001 10110 - 1010 ----------1100 10000 1 ----------1111 10010 - 1101 ----------101
29
In subtraction, a borrow of 1 (decimal sixteen ) is necessary. Examples: B - 6 -----5 10 - 8 ------8 18 - 9 -----F DE - C8 ------16 40C E -------3FE
30
31
SPACE
EJECT
END
Example:
LABEL
These and the DS/DC instructions are explained in the HLASM (High Level Assembler) Language Reference SC26-4940 which can be found in the HLASM Bookshelf.
32
PACK UNPK
D1(L1,B1),D2(L2,B2) D1(L1,B1),D2(L2,B2)
33
Some guidelines: 1. The Convert to Decimal instruction converts a 32-bit binary integer into an 8-byte packed decimal number. The binary integer must be in a register and the receiving field will be 8 bytes long. 2. The Convert to Binary instruction converts an 8-byte packed decimal number into a 32-bit binary integer in a register specified by the R1 operand. The sending field must be a valid packed decimal number.
34
PACK
PACKED,ZONED
Before
00 00 00 00
PACKED
F1 F2 F3 C4
ZONED
After
00 01 23 4C
PACKED
F1 F2 F3 C4
ZONED
35
Zoned Decimal)
PACKED(3),ZONED(4)
Before
00 00 00 00
PACKED
F1 F2 F3 C4
ZONED
After
01 23 4C 00
PACKED
F1 F2 F3 C4
ZONED
36
Zoned Decimal)
ZONED,ZONED
Before: F1 F2 F3 C4
ZONED
After: 00 01 23 4C
ZONED
37
Before 00 F1 88 08
REG 6
00 00 00 00 00 00 10 1C
PKDDBL
After 00 00 00 65
REG 6
00 00 00 00 00 00 10 1C
PKDDBL
38
MR
R6,R3
Before: FA 21
REG 6
19
1C
00
REG 7
00
01
23
00
REG 3
00
00
04
After: 00
REG 6
00
00
00
00
REG 7
00
04
8C
00
REG 3
00
00
04
39
CVD
R6,PKDDBL
Before: 00 00 00 64
REG 6
00 10 20 30 40 50 6F FF
PKDDBL
After: 00 00 00 64
REG 6
00 00 00 00 00 00 10 0C
PKDDBL
40
UNPK
ZONED,PACKED
Before:
F1 F2 F3 C4
ZONED
45 6D
PACKED
After:
F0 F4 F5 D6
ZONED
45 6D
PACKED
41
Packed Decimal)
NOTBIG,TOOBIG
Before: 00 00 00 00
NOTBIG
01 23 45 6C
TOOBIG
After: F3 F4 F5 C6
NOTBIG
01 23 45 6C
TOOBIG
Truncation of significant digits occurs. The receiving field was not large enough to receive all digits, but processing continues with, perhaps, undesireable results.
42
UNPK
PACKED,PACKED
Before: 01 23 45 6C
ZONED
After: ?? ?? ?? C6
ZONED
43
This instruction copies only the left-most 4 bits of each of the designated bytes of the source fields into the destination fields. The right-most 4 bits are not altered. Format: MVZ SAVE DC MVZ SAVE before: F1 F2 F3 C4 D1(L1,B1),D2(B2) Z'1234' SAVE+3(1),SAVE+2
SAVE after: F1 F2 F3 F4
44
45
46
{LABEL} - Label or name DC - Operation code {D} - Duplication factor T - Type (B, C, Z, P, H, F, D, X, A, V) {LN} - Length 'CONSTANT' - Actual constant value (nominal value) Items within brackets are optional. Constant data, within single apostrophes, must be coded. Maximum length of 256 for define constants.
47
Comments Each character is converted to its 8-bit EBCDIC representation. The characters are stored in consecutive bytes. Padding occurs with blanks in unoccupied bytes to the right. Truncation may occur, on the right. Fullword The number is converted to its 32-bit binary integer format (including sign). Max value 2,147,483,647 Halfword The number is converted to its 16-bit binary integer format (including sign). Max value 32,767 Doubleword Approximate max value: 7.2 x 10(75). Floating point constants not used in TPF.
Alignment Byte
48
Alignment Byte
Byte
Hexadecimal Byte
Comments Each digit is converted to a 4-bit binary integer. Max of 31 digits. Decimal point is ignored, e.g. P'3.5' is the same as P'35'. Zero fill with 4-bit zeroes to the left and truncation is on the left. Each digit is converted to an 8-bit EBCDIC format, max of 16 digits. The decimal point is ignored as in packed format. Zero fill with character zeroes (F0) to the left and truncation is on the left. Each digit must be one of the 16 hex digits and will be represented by a 4-bit binary number. Decimal point not allowed. Zero fill left, truncation on left.
49
Alignment Byte
Fullword
Fullword
Comments The bits are represented as given in the DC statement 8 bits per byte. Zero fill to the left and truncation on the left. The value of the symbol as a binary integer will be be stored. Space is reserved for an external address.
50
ZERO 000000 000008 000009 00000C 000010 000012 000013 000014 000015 0000000000000000 00 000000 00000000 0000 0C 00 F0 C0 DC DC D'0' X'0' F'0' H'0' P'0' B'0' C'0' Z'0' OF ONE X'1' F'1' H'1' P'1' B'1' C'1' Z'1'
01 00 00000001 0001 1C 01 F1 C1
FULLWORD DC HALFWORD DC DECIMAL DC BINARY DC CHAR DC ZONED DC ** ** CONSTANTS ** AHEX DC AFULL AHALF ADEC ABIN ACHAR AZONE DC DC DC DC DC DC
51
52
HALF2
DC HALF2
H'18' 00 12
HALF3
DC HALF3
H'-18' FF EE
HALF4
DC HALF4
2H'4' 00 04 00 04
53
FULLWD1
FULLWD2
DC
F'32' 00 00 00 20
FULLWD2
FULLWD3
DC
F'-32' FF FF FF E0
FULLWD3
FULLWD4
DC
2F'32' 00 00 00 20 00 00 00 20
FULLWD4
54
R6,FULL
Before: DO N'T CA RE
REG 6
00
REG 7
00
00
10
00
FULL
00
00
04
After: 00
REG 6
00
00
00
00
REG 7
00
00
40
00
FULL
00
00
04
55
MH
R5,HALF
Before: 00
REG 5
00
00
0A
00
HALF
03
After: 00
REG 5
00
00
1E
00
HALF
03
56
AR
R3,R4
Before: 01
REG 3
A2 30
11
02
REG 4
13
75
A6
After: 03
REG 3
B5
A5 B7
02
REG 4
13
75
A6
57
SR
R3,R4
Before: 00
REG 3
00
00
39
00
REG 4
00
00
12
After: 00
REG 3
00
00
27
00
REG 4
00
00
12
58
DR
R6,R2
Before: 00
REG 6
00
00
00
00
REG 7
00
00
2E
00
REG 2
00
00
08
After: 00 00 00 06 00 00 00 05
REG 6 (REM.)
REG 7 (QUOTIENT)
00
REG 2
00
00
08
59
R3,FULL
Before: 00
REG 3
00
00
06
00
FULL
00
00
04
After: 00
REG 3
00
00
0A
00
FULL
00
00
04
60
R3,FULL
Before: 00 00 00 0A 00 00 00 C8
REG 3 (+10)
FULL (+200)
After: FF FF FF 42 00 00 00 C8
REG 3 (-190)
FULL (+200)
61
R6,FULL
Before: 00
REG 6
00
00
00
00
REG 7
00
36
92
00
FULL
00
00
03
After: 00 00 00 02 00 00 12 30
REG 6 (REM.)
REG 7 (QUOTIENT)
00
FULL
00
00
03
62
Regardless of the value in the odd register, the dividend now occupies registers 6 and 7 with the correct sign and padding.
63
AH
R3,HALF
Before: 00
REG 3
00
00
0A
00
HALF
03
After: 00
REG 3
00
00
0D
00
HALF
03
64
AH
R3,HALFNEG
Before: 00 00 00 0A FF F1
REG 3 (+10)
HALFNEG (-15)
After: FF FF FF FB FF F1
REG 3 (-5)
HALFNEG (-15)
65
SH
R3,HALF
Before: 00
REG 3
00
00
0A
00
HALF
03
After: 00
REG 3
00
00
07
00
HALF
03
66
LR
R4,R5
Reg 4 before: 00 81 34 77
Reg 5 before: 00 00 12 11
Reg 4 after: 00 00 12 11
Reg 5 after: 00 00 12 11
67
LH
R7,TWOBYTS
TWOBYTS
00
48
Reg 7 after: 00 00 00 48
TWOBYTS after: 00 48
68