I am a beginner in Assembler.I had a doubt while learning assembler regarding registers.Here is my understanding about register and my question.Please correct me where I am wrong.
Register is a pointer stores address.Each register contains 4 bytes.(32 bits).
Base register will be storing address of program instructions and its displacements.Since register is 4byte in memory and it holds hexadecimal addresses maximum address values that can be hold by base register is
X'FFFFFFFF'.But one nibble (4bits) is for indicating the register.So,Maximum displacement allowed in base register is X'FFFFFFF'.
But actually it is said that one base register can hold maximum 4096 bytes of instructions.Which is X'FFF' and one nibble for register indicator so X'BFFF'.X'BFFF' occupies only 2 bytes then what will be there in other two bytes.I know I am missing some thing basically.But i could not find.Please help.
I have seen the listing also. there base address displacement was in 6 digits which adds me more confusion.Please clarify me.
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
Hello,
One thing you should invest in is a Good beginners Assembler book. The one I've used most was written by Kevin McQuillan and is/was available from Mike Murach Publishing. I believe it is now an e-book - this is the second assembler Kevin wrote - this one with Anne Prince. His first book is out of print, but copies are around if one looks.
Another is to download a copy of the Principles of Operations manuals from IBM. This will tell you all of the detail you might want/need for every instruction.
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
Quote:
Register is a pointer stores address.Each register contains 4 bytes.(32 bits).
Base register will be storing address of program instructions and its displacements.Since register is 4byte in memory and it holds hexadecimal addresses maximum address values that can be hold by base register is
X'FFFFFFFF'.But one nibble (4bits) is for indicating the register.So,Maximum displacement allowed in base register is X'FFFFFFF'.
But actually it is said that one base register can hold maximum 4096 bytes of instructions.Which is X'FFF' and one nibble for register indicator so X'BFFF'.X'BFFF' occupies only 2 bytes then what will be there in other two bytes.I know I am missing some thing basically.But i could not find.Please help.
Much of what you have posted is incorrect.
First, there are 24-bit addresses, 31-bit addresses, and 64-bit addresses possible on a z/OS system. 24-bit addressing came first, then 31-bit, then 64-bit. 24-bit addresses are indicated by the first bit (reading left to right) being zero; if that bit is 1 then you have a 31-bit address. 64-bit addressing won't be considered here since you are a beginner.
Second, 31-bit addresses can use all 31 bits (since the first bit of the 32 bits in the word is an indicator bit) -- there are no nybbles reserved for "register indicator". 24-bit addresses will not use any of the leftmost 8 bits of each 4-byte word. I leave it to you to compute the maximum possible 24-bit and 31-bit address.
Third, base registers may contain any valid address. HOWEVER, the offset from the base register may not exceed 4096. If the base register value is loaded at X'4F200000', then the maximum offset / displacement for that base register will be at address X'4F200FFF'.
Fourth, why 4096? Because 3 nybbles (12 bits) is what assembler instructions (going back to 1964 and the original S/360 system) allowed for displacements / offsets.
Fifth, when you assemble a program, on the left side you will see the machine code for each assembler instruction, the 4-bit base register for each operand of that instruction, and the offset (12 bits) for each operand.