4.9 Shifting and byte swapping
4.8.1 Memory bit test and clear or set
Bits of a word in memory may be tested and set or cleared by the instruction rmw. The
address of the memory word is held in Areg and a bit masks in Breg and Creg. rmw
clears the bits of the memory word that are set in Creg, and then sets the bits of the
memory word that are set in Breg.The initial memory word is loaded into Areg, with
Areg pushed down to Breg and Breg pushed down to Creg.
4.9 Shifting and byte swapping
The shift and byte swapping operations are provided by the instructions listed in Table
4.11.
Mnemonic
Name
shl
shift left
shr
shift right
ashr
arithmetic shift right
swap32
byte swap 32
Table 4.11 Shifting and byte swapping instructions
The shift operations (shl, shr and ashr) shift the operand in Breg by the number of bits
specified b y the unsigned integer in Areg and put the result in Areg. shl and shr fill the
vacated bit positions with zero bits, while ashr fills the vacated bits with copies of bit
31, which is the original sign bit. If Areg is zero, the result is the initial value of Breg.
When the value in Areg is greater than the number of bits in the object being shifted,
the result of the operation is undefined. The data previously held in Creg is popped
into Breg, and the initial Breg is left in the Creg.
swap32 reverses the order of the bytes in Areg by swapping byte 0 with byte 3 and
swapping byte 1 with byte 2.
4.10 Function and procedure calls
The function and procedure call operations are provided by the instructions listed in
Table 4.12.
Mnemonic
Name
fcall
function call
jab
jump absolute
ajw
adjust work space
gajw
general adjust workspace
Table 4.12 Function and procedure instructions
The primary instruction fcall n calls a function or procedure. It stores the instruction
pointer (which holds the return address) in the word pointed to by the Wptr. The
operand to the call - n - is added to the address of the next instruction to produce the
address of the first instr uction of the procedure or function being called. Since the call
address is relative, the code is relocatable.
48/205
®