
2-38
MPC603e & EC603e RISC Microprocessors User's Manual
MOTOROLA
2.3.4.6.1 Move to/from Condition Register Instructions
Table 2-37 lists the instructions provided by the 603e for reading from or writing to the CR.
2.3.4.7 Memory Synchronization Instructions—UISA
Memory synchronization instructions control the order in which memory operations are
completed with respect to asynchronous events, and the order in which memory operations
are seen by other processors or memory access mechanisms. See Chapter 3, “Instruction
and Data Cache Operation,” for additional information about these instructions and about
related aspects of memory synchronization.
The
sync
instruction delays execution of subsequent instructions until previous instructions
have completed to the point that they can no longer cause an exception and until all previous
memory accesses are performed globally; the
sync
operation is not broadcast onto the 603e
bus interface. Additionally all load and store cache/bus activities initiated by prior
instructions are completed. Touch load operations (
dcbt
and
dcbtst
) are required to
complete at least through address translation, but not required to complete on the bus.
The functions performed by the
sync
instruction normally take a significant amount of time
to complete; as a result, frequent use of this instruction may adversely affect performance.
In addition, the number of cycles required to complete a
sync
instruction depends on
system parameters and on the processor's state when the instruction is issued.
The proper paired use of the
l
wa
rx
and
stwcx.
instructions allows programmers to emulate
common semaphore operations such as “test and set,” “compare and swap,” “exchange
memory,” and “fetch and add.” Examples of these semaphore operations can be found in
Appendix E, “Synchronization Programming Examples,” in
The Programming
Environments Manual
. The
lwarx
instruction must be paired with an
stwcx.
instruction
with the same 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 upon the existence of a reservation established by the preceding
lwarx
instruction. If the reservation exists when the store is executed, the store is performed and
a bit is set 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.
Table 2-30. Move to/from Condition Register Instructions
Name
Mnemonic
Operand Syntax
Move to Condition Register Fields
mtcrf
CRM
,r
S
Move to Condition Register from XER
mcrxr
crf
D
Move from Condition Register
mfcr
r
D