Texas Instruments MSP430x1xx User Manual page 96

Texas instruments modules and peripherals user's guide
Table of Contents

Advertisement

Instruction Set
RRA[.W]
Rotate right arithmetically
RRA.B
Rotate right arithmetically
Syntax
RRA
RRA.B
Operation
MSB −> MSB, MSB −> MSB−1, ... LSB+1 −> LSB,
Description
The destination operand is shifted right one position as shown in Figure 3−16.
The MSB is shifted into the MSB, the MSB is shifted into the MSB−1, and the
LSB+1 is shifted into the LSB.
Figure 3−16. Destination Operand—Arithmetic Right Shift
Status Bits
N: Set if result is negative, reset if positive
Z: Set if result is zero, reset otherwise
C: Loaded from the LSB
V: Reset
Mode Bits
OSCOFF, CPUOFF, and GIE are not affected.
Example
R5 is shifted right one position. The MSB retains the old value. It operates
equal to an arithmetic division by 2.
RRA
;
The value in R5 is multiplied by 0.75 (0.5 + 0.25).
;
PUSH
RRA
ADD
RRA
......
Example
The low byte of R5 is shifted right one position. The MSB retains the old value.
It operates equal to an arithmetic division by 2.
RRA.B
PUSH.B
RRA.B
ADD.B
......
RISC 16−Bit CPU
3-60
dst
or
dst
Word
15
C
Byte
15
R5
; R5/2 −> R5
R5
; Hold R5 temporarily using stack
; R5 × 0.5 −> R5
R5
; R5 × 0.5 + R5 = 1.5 × R5 −> R5
@SP+,R5
; (1.5 × R5) × 0.5 = 0.75 × R5 −> R5
R5
R5
; R5/2 −> R5: operation is on low byte only
; High byte of R5 is reset
; R5 × 0.5 −> TOS
R5
; TOS × 0.5 = 0.5 × R5 × 0.5 = 0.25 × R5 −> TOS
@SP
; R5 × 0.5 + R5 × 0.25 = 0.75 × R5 −> R5
@SP+,R5
RRA.W
dst
LSB −> C
0
0

Advertisement

Table of Contents
loading

Table of Contents