Lwarx - IBM PPC440X5 CPU Core User Manual

Cpu core
Table of Contents

Advertisement

Preliminary

lwarx

Load Word and Reserve Indexed
lwarx
RT, RA, RB
31
0
6
EA
(RA|0) + (RB)
RESERVE
1
(RT)
MS(EA,4)
An effective address (EA) is formed by adding an index to a base address. The index is the contents of
register RB. The base address is 0 if the RA field is 0 and is the contents of register RA otherwise.
The word at the EA is placed into register RT.
If instruction bit 31 contains 1, the contents of CR[CR0] are undefined.
Execution of the lwarx instruction sets the reservation bit.
Registers Altered
• RT
Invalid Instruction Forms
• Reserved fields
Programming Note
The lwarx and stwcx. instructions are typically paired in a loop, as shown in the following example, to create
the effect of an atomic operation to a memory area used as a semaphore between multiple processes. Only
lwarx can set the reservation bit to 1. stwcx. sets the reservation bit to 0 upon its completion, whether or not
stwcx. actually stored (RS) to memory. CR[CR0]
memory.
loop: lwarx
# read the semaphore from memory; set reservation
"alter"
# change the semaphore bits in the register as required
stwcx.
# attempt to store the semaphore; reset reservation
bne loop
# some other process intervened and cleared the reservation prior to the above
# stwcx.; try again
The PowerPC Book-E architecture specifies that the EA for the lwarx instruction must be word-aligned (that
is, a multiple of 4 bytes); otherwise, the result is undefined. Although the PPC440x5 will execute lwarx
regardless of the EA alignment, in order for the operation of the pairing of lwarx and stwcx. to produce the
desired result, software must ensure that the EA for both instructions is word-aligned. This requirement is due
to the manner in which misaligned storage accesses may be broken up into separate, aligned accesses by
the PPC440x5.
instrset.fm.
September 12, 2002
RT
RA
11
must be examined to determine whether (RS) was sent to
2
PPC440x5 CPU Core User's Manual
RB
16
21
lwarx
Load Word and Reserve Indexed
20
Page 339 of 589
31

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents