HLASM - LA = Load Address

The opcode of the LA instruction is X'41'.

Usage

  1. Obtain a pointer to a specific field or area of storage.
  2. Load a register with a number (in the range 0 through 4095, inclusive).
  3. Increment a pointer by a fixed amount, e.g. to step through the elements in a table.
  4. Decrement a pointer by a fixed amount.

Arguments

  1. Register to receive the address.
  2. 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

  1. 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.
  2. The computed address is loaded into the first operand register as follows:
  3. The condition code does not change.

Special Cases

  1. If the base register is register 0, then it does not participate in the address calculation.
  2. If the index register is register 0, then it does not participate in the address calculation.
  3. 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

  1. BALR may be used to obtain a pointer to the next instruction in the program.
  2. LAY differs from LA only in that is uses a 20-bit displacement.
  3. LAE also loads the register with the computed address, but additionally loads the associated access register with the the appropriate ALET.
  4. LARL loads the register with an address that is relative to the instruction's address in storage.

Hardware

  1. All hardware supports the LA instruction.

Remarks

  1. 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.
  2. 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.
Running Tyrannosaurus Rex 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.