HLASM - LA = Load Address
The opcode of the LA instruction is X'41'.
Usage
- Obtain a pointer to a specific field or area of storage.
- Load a register with a number (in the range 0 through 4095,
inclusive).
- Increment a pointer by a fixed amount, e.g. to step through the elements
in a table.
- Decrement a pointer by a fixed amount.
Arguments
- Register to receive the address.
- Storage address to be loaded, or number to be loaded.
A storage address is made up of a base address, an index address, and a
displacement. A number corresponds to a storage address with both base and
index register being zero.
Function
- The processor adds the contents of the base and index registers, then
adds the displacement. For both additions the current Amode determines how
many bits are used for operands and result. The displacement, however, is
always 12 bits. Any overflow is ignored.
- The computed address is loaded into the first operand register as
follows:
- in Amode 24 the computed address is loaded into the low-order three
bytes and the high-order byte of the 32-bit register is set to zero.
- in Amode 31 the computed address is loaded into the 32-bit register
and its high-order bit is set to zero.
- in Amode 64 the computed address is loaded into the 64-bit
register.
- The condition code does not change.
Special Cases
- If the base register is register 0, then it does not participate in the
address calculation.
- If the index register is register 0, then it does not participate in the
address calculation.
- If both base and index register are register 0, then neither participates
in the address caculation. Thus, the displacement will be loaded as is.
Related Instructions
- BALR may be used to obtain a pointer to the next
instruction in the program.
- LAY differs from LA only in that is uses a 20-bit
displacement.
- LAE also loads the register with the computed
address, but additionally loads the associated access register with the
the appropriate ALET.
- LARL loads the register with an address that is
relative to the instruction's address in storage.
Hardware
- All hardware supports the LA instruction.
Remarks
- All programmers confuse L and LA (Load and Load
Address, repectively) sometime. Load moves the contents from memory into the
specified register. Load Address does not access memory. It only calculates
a number or an address. As a register only instruction, it executes faster
than Load.
- A pointer can be decremented by adding a negative amount.
Examples
TABENT DSECT , * Map table entry
TABFLD1 DS CL6 * Some field
TABFLD2 DS CL6 * Another field
TABENT_LEN EQU *-TABENT * Length of tabel entry
TABENT_COUNT EQU 10 * Nr of entries in table
...
YREGS * Define register names
...
* This is a routine to initialize a table
USING TABENT,R14 * Use DSECT to address table entry
LA R14,TABLE * Point to the table
LA R0,TABENT_COUNT * Load number of entries
*
INITTBL MVC FIELD1,SPACES * Move data to the table entry
MVC FIELD2,ZEROS * Move more data to the table entry
LA R14,TABENT_LEN(R14) * Bump to the next table entry
BCT R0,INITTBL * and loop through the entire table
...
* Back up to previous entry
LA R15,TABENT_LEN * Get length of entry
LNR R15,R15 * Make negative
LA R14,0(R14,R15) * Point previous entry
...
SPACES DC (L'FIELD1)C' ' * As many spaces / zeroes
ZEROS DC (L'FIELD2)C'0' * as needed to prime an entry
TABLE DS (TABENT_COUNT)CL(TABENT_LEN)
...
To the Opcodes Overview.
To the English Homepage for Hlasm.com.
To the General Homepage for Bixoft and Hlasm.com.
This site is a member of WebRing.
You are invited to browse the
list of mainframe-loving sites.
|
|
Dinos are not dead. They are alive and well and living in data centers all
around you. They speak in tongues and work strange magics with computers.
Beware the dino! And just in case you're waiting for the final demise of
these dino's: remember that dinos ruled the world for 155-million years!
|
Dinos and other anachronisms
[ Join Now
| Ring Hub
| Random
|
<< Prev
|
Next >>
]
|
Below you find the logo of our
sponsor
and logos of the web-standards that this page adheres to.