360 Assembly/360 Instructions/LA

< 360 Assembly < 360 Instructions

LA - Load Address - Opcode 41 - RX format Instruction (32 Bit)

Format

LA 2,N2
LA 11,106(8,10)

The specific syntax is

LA target register,offset(index register,base register)

If a label is used instead of explicit index and base register and offset, then the offset, index register and base register values will be determined automatically by the assembler if the USING pseudo-instruction has been used, and the target address label used is within 4095 bytes of the value of some base register.

RX Instruction (4 bytes)
Byte 1 Byte 2 Bytes 3 and 4
target register Source Address
(8 bits)
Opcode
41
(4 bits)

0..F
(4 bits)
index
register

0..F
(4 bits)
base
register

0..F
(12 bits)
offset
0..FFF

Availability

The LA instruction is available on all models of the 360, 370 and z/System.

Condition code

This instruction does not alter the condition code.

Usage

The LA instruction has three general uses.

Note that unlike most instructions, the LA instruction is used to place a value into a register; the resulting address does not have to correspond to an actual address and is not checked for validity. Overflow cannot occur as the top bit of the result is always set to 0, and in 24-bit mode, the top 7 bits of the result are set to 0.

The LA instruction could be used to clear the value of a register by using 0 for the base, index and displacement values; the actual value in register 0 would not be used and the register would be zeroed. However, the SR or XR instruction with the same register number for both arguments will zero a register faster and produces a shorter instruction.

Operation

The LA instruction computes either a 31-bit value (if the program is running in 31-bit or 64-bit address mode) or a 24-bit value from the address specified by the second argument and stores it in the register specified by the first argument, clearing the high bit (0) in 31-bit or 64-bit mode, and the high byte (bits 0-7) in 24-bit mode. The address is computed by using the base-displacement value of the address. The address value, from 0 to 4095, is added to the value of the contents of the base register (unless it is register 0, then it is presumed to contain zero). To this is added the value of the contents of the index register (unless it is register 0, then it is also presumed to contain zero). In 31-bit or 64-bit mode, the high bit is forced to 0. In 24-bit mode, the high byte is forced to 0. This total is then stored in the target register. This value does not have to be a valid address; while the LA instruction is often used to compute an address, it can be used to set the value of a register, e.g. a way to increment register 1 by 1 is the following:

LA 1, 1(0,1)

Or to increment register 7 by 5

LA 7, 5(0,7)

In some cases, the LA instruction is used to create addressing for program segments larger than 4095 bytes, by arranging a second register to point 4096 bytes after the first:

ROUTINE  CSECT
         BALR  12,0
         USING *,12,11
         LA    11,4095(0,12)      Register 0 explicitly stated as the index register
         LA    11,1(11)           Register 0 is implied for the Index register

In the above case, register 12 is the base register for the first 4096 bytes of the routine, and register 11 is the base register for the portion of the program above 4096 bytes.

Exceptions and Faults

None. The address being generated is not checked for validity, and because in all modes (24-bit, 31-bit or 64-bit), bit 0 is always cleared, overflow cannot occur.

32-Bit Instructions

64-Bit Instructions

Previous Instruction
L
360 Assembly Instructions   Next Instruction
LAE
Previous Opcode
40
Next Opcode
42
360 Assembly Language
360 Family Introduction · Basic FAQ · 360 Family · 360 Architecture
360 Instruction Set 360 Instructions · Branch Instructions · Data Transfer Instructions · Control Flow Instructions · Arithmetic Instructions · Logic Instructions · Shift and Rotate Instructions · Other Instructions
Syntaxes and Assemblers 360 Assemblers· Pseudo Instructions
Instruction Extensions Floating Point · High-Level Languages
This article is issued from Wikibooks. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.