Rev. 1.50, 10/04, page 311 of 448
10.1.63 SHAR (Shift Arithmetic Right): Shift Instruction
Format Operation Instruction Code Cycle T Bit
SHAR Rn MSB → Rn → T 0100nnnn00100001 1 LSB
Description:
This instruction arithmetically shifts the contents of general register Rn one bit to the right, and
stores the result in Rn. The bit shifted out of the operand is transferred to the T bit.
MSB LSB
SHAR
T
Notes: None
Operation:
SHAR(long n) /* SHAR Rn */
{
long temp;
if ((R[n]&0x00000001)==0) T = 0;
else T = 1;
if ((R[n]&0x80000000)==0) temp = 0;
else temp = 1;
R[n] >>= 1;
if (temp==1) R[n] |= 0x80000000;
else R[n] &= 0x7FFFFFFF;
PC += 2;
}
Example:
SHAR R0 ;Before execution R0 = H'80000001, T = 0
;After execution R0 = H'C0000000, T = 1