lswx or lsx (Load String Word Indexed) instruction

Purpose

Loads consecutive bytes in storage from a specified location in memory into consecutive general-purpose registers.

Syntax

Bits Value
0 - 5 31
6 - 10 RT
11 - 15 RA
16 - 20 RB
21 - 30 533
31 /
PowerPC® 
lswx RT, RA, RB
POWER® family 
lsx RT, RA, RB

Description

The lswx and lsx instructions load N consecutive bytes in storage addressed by the effective address (EA) into general-purpose register (GPR) RT, starting with the leftmost byte, through GPR RT + NR - 1, and wrapping around back through GPR 0 if required.

If GPR RA is not 0, the EA is the sum of the contents of GPR RA and the address stored in GPR RB. If GPR RA is 0, then EA is the contents of GPR RB.

Consider the following when using the lswx and lsx instructions:

  • XER(25-31) contain the byte count.
  • RT is the starting general-purpose register.
  • N is XER(25-31), which is the number of bytes to load.
  • NR is ceiling(N/4), which is the number of registers to receive data.
  • If XER(25-31) = 0, general-purpose register RT is not altered.

For the PowerPC® instruction lswx, if RA or RB is in the range of registers to be loaded or RT = RA = 0, the results are boundedly undefined.

Consider the following when using the POWER® family instruction lsx:

  • If GPR RT + NR - 1 is only partially filled on the left, the rightmost bytes of that general-purpose register are set to 0.
  • If GPRs RA and RB are in the range to be loaded, and if GPR RA is not equal to 0, then GPR RA and RB are not written into by this instruction. The data that would have been written into them is discarded, and the operation continues normally.

The lswx and lsx instructions have one syntax form which does not affect the Fixed-Point Exception Register or Condition Register Field 0.

Note: The lswx and lsx instructions can be interrupted by a Data Storage interrupt. When such an interrupt occurs, the instruction is restarted from the beginning.

Parameters

Item Description
RT Specifies starting general-purpose register of stored data.
RA Specifies general-purpose register for EA calculation.
RB Specifies general-purpose register for EA calculation.

Examples

The following code loads the bytes contained in a location in memory addressed by GPR 5 into GPR 6:


# Assume XER25-31 = 4.
csect data[rw]
storage: .string "Hello, world"
# Assume GPR 4 contains the displacement of storage
# relative to data[rw].
# Assume GPR 5 contains the address of csect data[rw].
.csect text[pr]
lswx 6,5,4
# GPR 6 now contains 0x4865 6c6c.