Addressing 24-bit storage and 31-bit storage
System 370 (predecessor to System z) could only address 16MB of storage when I started to learn assembler and we did not have words for addressing mode(s). Therefor creative people used the high order byte of an address as a sort of parameter to the address that was in the low order three bytes. One example is an address in the Data Control Block (DCB):
0001E0 00 269+ DC BL1'00000000' BFTEK, BFALN, DCBE INDICATORS
0001E1 0000AE 270+ DC AL3(CLOSE) EODAD (END OF DATA ROUTINE ADDRESS)
|
The address of the End Of Data routine is only 24 bit long. That is why the DCB is still located below the line.
Bear in mind that the general registers have always been four bytes each.
I have made a small program that just reads records and writes them out again. This is a part of it which I will play with in the following articles in this series.
BAL R14,OPENIN
BAL R14,OPENOUT
READ DS 0H
BAL R14,READIN
L R2,RECADR
MVC OUTREC,0(R2)
BAL R14,WRITE
B READ
CLOSE DS 0H
DROP R9
BAL R14,CLOSEIN
BAL R14,CLOSEOUT
B RETURN
|
24-bit addressing mode was sufficient for a long time. In the 70’s came eXtended Architecture (XA) though which meant you could now address 2GB of storage. It was a game changer in assembler programming. IBM has always protected the customer's investment in their software (Cobol, PL1, and Assembler) so the XA-system had to be backward compatible. One single bit in the PSW did that. The high order bit in the instruction address in the PSW told the CPU whether, when zero, it run in addressing mode 24 or in 31-bit addressing mode (addressing mode 31) when one.
Addressing mode 24 PSW: 078D0000 00007E1A - The high order bit is off
Addressing mode 31 PSW: 078D1000 80007DFE - The high order bit is on
In addressing mode 24 the instructions work as usual but in addressing mode 31 some of the instructions work a little bit different. They now have to take the longer storage address into account. An example
Addressing mode 24
LA R1,BELOW16
R1 will after this instruction contain the address of BELOW16 in the three rightmost bytes and the leftmost byte will be zero.
Addressing mode 31
LA R1,ABOVE16
R1 will now contain the address in all four bytes except the high order bit that will be zero. Sometimes referred to as an XA-address.
Change mode
We suddenly encountered a problem in our legacy addressing mode 24 programs if we had to address storage “above the line” as the 16MB limit was called. We couldn’t just change the addressing mode for the whole program because we might be using the leftmost byte as parameter bits. In that case we could use some new instructions that could flip the high order bit of the PSW i.e. go to addressing mode 31 and back to addressing mode 24.
BAL R14,OPENIN
BAL R14,OPENOUT
GETMAIN RC,LV=WS31_LEN,LOC=(31,64)
LR R9,1
USING WS31,R9
READ DS 0H
BAL R14,READIN
L R2,RECADR
LA R3,LABEL31
O R3,=X'80000000'
BSM 0,R3
LABEL31 DS 0H
MVC RECORD31+1(80),0(R2)
MVC OUTREC,RECORD31
LA R3,LABEL24
N R3,=X'7FFFFFFF'
BSM 0,R3
LABEL24 DS 0H
BAL R14,WRITE
B READ
|
Partial addressing mode 31 program.
I admit this is a stupid program but I have made it to show how you can change mode to addressing mode 31 in a program that otherwise is addressing mode 24. I Getmain some storage “above the line”. R9 will contain an XA-address. Ex:
R9: 1F700F78
I intend to move the read record to RECORD31. Right after I move it back “below the line” to OUTREC. I then must go back to addressing mode 24 in the running program in order to be able to write the record.
Instructions to go from addressing mode 24 to addressing mode 31
LA R3,LABEL31
O R3,=X'80000000'
BSM 0,R3
LABEL31 DS 0H
|
- I start to load the address of the first addressing mode 31 instruction at LABEL31
- Then I set the high order bit on that address to indicate that from this address I can reach above the line
- BSM is Branch and Set Mode. The first argument is set to zero because I just need to branch to the address in second argument
- LABEL31 is the location counter of the first addressing mode 31 instruction
All following instructions executed will be in addressing mode 31 until I do the following instructions. Actually the opposite of the previous.
LA R3,LABEL24
N R3,=X'7FFFFFFF'
BSM 0,R3
LABEL24 DS 0H
|
Instructions to go from addressing mode 31 to addressing mode 24
- I start to load the address of the first addressing mode 24 instruction at LABEL24
- Then I set the high order bit off that address to indicate that I am now unable to reach above the line
- BSM is Branch and Set Mode. The first argument is set to zero because I just need to branch to the address in second argument
- LABEL24 is the location counter of the first addressing mode 24 instruction
New addressing mode 31 program
Although 24-bit addressing mode is the default if you do not specify anything neither in the assembler source nor the linkage editor, you will probably wish to write addressing mode 31 programs. You will probably also wish to locate your program “above the line”, i.e. in 31-bit storage area. In order to do so you may either code the RMODE 31 in the assembler source or as input to the linkage editor
Specified in the source or in linkage editor
|
Result
|
AMODE UNSPECIFIED
RMODE UNSPECIFIED
|
AMODE 24
RMODE 24
|
AMODE UNSPECIFIED
RMODE ANY or 31
|
AMODE 31
RMODE 31
|
AMODE 31
RMODE UNSPECIFIED
|
AMODE 31
RMODE 24
|
AMODE 31
RMODE ANY
|
AMODE 31
RMODE 31
|
Just specify RMODE 31 and you are are also in addressing mode 31.
If the program is located in 31-bit storage it must also be in addressing mode 31 because the base register(s) will have to address the instructions. So just make the RMODE-instruction 31 or ANY.
PGM5 CSECT
PGM5 RMODE ANY
ENTRY PGM5
|
How to start your CSECT if running AMODE 31 and RMODE 31
The best way to make sure that your program is in the right mode is to take a look at the directory entry for the loadmodule. You can find the modes on the very right of the program entry.
Next time I will explore the possibilities of the 64-bit programming. That will be fun!
BROWSE JEE.LOADLIB Row 0000001 of 0000003
Command ===> Scroll ===> CSR
Name Prompt Alias-of Size TTR AC AM RM
_________ PGM1 000001B8 00000C 00 31 ANY
_________ PGM5 00001140 00042F 00 31 ANY
_________ PGM6 000002C8 000404 00 24 24
|
The "G" in the 64 bit commands is said to mean "Grande", taken from the coffee cup size they were drinking, while designing the instructions.
SvarSletMichael Erichsen