
MOTOROLA
Chapter 3. Instruction Set Model
3-29
Instruction Set Summary
effective address used for both instructions of the pair. Note that the reservation granularity
is 32 bytes.
The concept behind the use of the
lwarx
and
stwcx.
instructions is that a processor may
load a semaphore from memory, compute a result based on the value of the semaphore, and
conditionally store it back to the same location (only if that location has not been modified
since it was first read), and determine if the store was successful. The conditional store is
performed, based on the existence of a reservation established by the preceding
lwarx
instruction. If the reservation exists when the store is executed, the store is performed which
sets a bit in the CR. If the reservation does not exist when the store is executed, the target
memory location is not modified and a bit is cleared in the CR.
If the store was successful, the sequence of instructions from the read of the semaphore to
the store that updated the semaphore appear to have been executed atomically (that is, no
other processor or mechanism modified the semaphore location between the read and the
update), thus providing the equivalent of a real atomic operation. However, in reality, other
cores may have read from the location during this operation. In the G2 core, the reservations
are made on behalf of aligned 32-byte sections of the memory address space.
The
lwarx
and
stwcx.
instructions require the EA to be aligned. Exception handling
software should not attempt to emulate a misaligned
lwarx
or
stwcx.
instruction, because
there is no correct way to define the address associated with the reservation.
In general, the
lwarx
and
stwcx.
instructions should be used only in system programs,
which can be invoked by application programs as needed.
At most, one reservation exists simultaneously on any processor. The address associated
with the reservation can be changed by a subsequent
lwarx
instruction. The conditional
store is performed, based on the existence of a reservation established by the preceding
lwarx
regardless of whether the address generated by the
lwarx
matches that generated by
the
stwcx.
instruction. A reservation held by the processor is cleared by one of the
following:
Executing an
stwcx.
instruction to any address
Attempt by some other device to modify a location in the reservation granularity
(32 bytes)
The
lwarx
and
stwcx.
instructions to write-through memory do not cause a DSI exception.
Table 3-25 lists the UISA memory synchronization instructions for the G2 core.
Table 3-25. Memory Synchronization Instructions—UISA
Name
Mnemonic
Operand Syntax
Load Word and Reserve Indexed
lwarx
r
D
,r
A
,r
B
Store Word Conditional Indexed
stwcx.
r
S
,r
A
,r
B
Synchronize
sync
—
F
Freescale Semiconductor, Inc.
For More Information On This Product,
Go to: www.freescale.com
n
.