











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
The concept of base registers in address calculation for the system/370. It discusses the sixteen general-purpose registers, their characterization as base registers, and the use of base register addressing. The document also covers instruction formats and register naming conventions.
Typology: Study notes
1 / 19
This page cannot be seen from the preview
Don't miss anything!












This lecture is the first of two on Chapter 6 of Peter Abel’s textbook. Today, we cover the use of base registers in address calculation. Topics for today include.
The System/370 uses 32–bit two’s–complement signed integers. The range of these integers is – 31 to 2 31
Note that there are two ways of writing the part of the standard prefix code. What we have discussed in these slides: *BALR 12, 0 USING , 12 What we have used in our labs: *BALR R12, 0 USING , R From this I infer that the assembler will accept either notation in places in which the syntax expects a register to be used. NOTE: The first line is a truncated subroutine call. The instruction says: 1. Store the address of the next instruction into R
By definition, a control section (CSECT) is “a block of coding that can be relocated (independent of other coding) without altering the operating logic of the program”. For the modern programmer, a CSECT might be considered as an independent code module or package. The match in terminology is not precise, but suggestive. Very large assembly language programs will require more than one control section. [My note: This is probably old information.] In any case, the programs we write will require only one CSECT, even assuming the addressing constraints imposed by the old System/370 architecture. A program with a single CSECT may be started in one of two ways. For example, the program LAB01 may be started in one of two ways. LAB01 START LAB01 CSECT The assembler allows for the specification of a load address in the START or CSECT. This is probably a bad idea; it may be ignored by a modern operating system.
The bottom line is “Don’t try this (at home)”. In other words, any attempt to use register 0 for anything other than temporary results is likely to cause problems.
computing the address. We shall use this later to load registers with positive constants. One has another option that might force register 0 to be a base register. We can start the program as follows. *BALR R0, 0 USING , R While this MIGHT assemble correctly (I have no idea), it is most certainly a very bad idea. Any call to a system procedure will disrupt the addressing.
So far, we have considered only the object code form of a typical address. We now “jump ahead” a bit and look at two typical instructions that use this address type. One type of instruction, called “RS”, used for register–to–storage instructions. Such an instruction has source code of the form OP R1,R3,D2(B2). Such an instruction has object code of the form OP R 1 R 3 B 2 D 2 D 2 D 2. We look at LM , an interesting example of this format. LM R1,R3,S2 loads multiple registers in the range R1 – R3 from the memory
We now interpret the following code fragment. *BALR R12, 0 Establish register R12 (X‘C’) USING , R12 as the default base resister. LM R5,R7,S2 might have object code 98 57 C1 00. This uses the default base register. LM R9,R11,S3(R3) might have object code 98 9B 32 00. Object code such as 98 9B 0E 00 would call for use of an absolute address, not computed from a base register. For this example, it is likely to be bad code.
The second major advantage of base/displacement addressing still applies today. “The system facilitates program relocatability. Instead of assigning specific [fixed] storage addresses, the assembler determines each address relative to a base address. At execute time [after the program is loaded], the base address, which may be anywhere in storage, is loaded into a base register.” The standard prefix code *BALR 12, 0 USING , 12 may be translated as follows:
In the 1960’s, code that did not reference absolute addresses was thought to be superior. It was called “position independent code”.
Here are some more examples of addressing using an index register and a base register. All of these examples are taken from type RX instructions, which use indexing. Each of these is a four–byte instruction of the form OP R1,D2(X2,B2). The format of the object code is OP R 1 X 2 B 2 D 2 D 2 D 2. Each byte contains two hexadecimal digits. We interpret the 32–bit object code as follows. OP This is an eight–bit operation code. R 1 X 2 This byte contains two hexadecimal digits, each of which is significant. R 1 denotes a register as the source or destination of the operation. X 2 denotes a general–purpose register to be used as an index register. B 2 D 2 D 2 D 2 This contains the argument address as a base register and displacement. Remember that the displacement, given by three hexadecimal digits, is treated as a 12–bit unsigned integer. In decimal, the limit is 0 Displacement 4095. The general form by which an address is computed is Contents (Base Register) + Contents (Index Register) + Displacement. Some instructions do not use index register addressing.
Here is some object code for analysis. 58 40 C1 23 The first thing to note is that the opcode, 58 , is that for L , a Register Load. This is a type RX instruction with object code of the form OP R 1 X 2 B 2 D 2 D 2 D 2. As noted above, OP = 58. We see that R 1 = 4. It is register 4 that is being loaded from memory. We see that X 2 = 0. Indexed addressing is not used. We also note that B 2 D 2 D 2 D 2 = C1 23 , indicating an offset of X‘123’ from the address value stored in general–purpose register 12 (hexadecimal C ). Suppose that the value in general–purpose register 12 is X‘2500’. The effective address for this instruction is then X‘2500’ + X‘123’ = X‘2623’.
Let’s look at the standard form used for a base & displacement address.
There are instructions in which the value so computed is just used as a value and not as an address. Consider the instruction SLL R4,1. It is assembled as shown below. 000018 8940 0001 00001 48 SLL R4, The base register is 0, indicating that no base register is used. The “offset” is 1. The value by which to shift is given as the sum, which is 1. We could use a standard register to hold the value of the shift count, as in the following, which uses R8 to hold the shift count. 000018 8940 8000 00001 48 SLL R4,0(R8) NOTE: This is a good example of not using a “base register” in order to generate an “absolute constant”, not relative to any address. Here, the value is a count.
If the program is to use a base register for base register/displacement addressing, that register must be specified and provided with an initial value. Again, the standard prefix code handles this. *BALR 12, 0 USING , 12 If register 12 is used as a base register, it cannot be used for any other purpose. In other words, your code should not reference register 12 explicitly. We have two standards suggested for a base register. The textbook uses register 3 and one of our examples uses register 12. Pick one and use it consistently.
There are six instruction formats of interest to us. These are classified by the type of transfer. RR Register to register transfers. RS Register to storage and register from storage RX Register to indexed storage and register from indexed storage SI Storage immediate SS There are two variants of these Storage to storage transfer instructions.