Texas Instruments MSP430x1xx User Manual
Page 400

Running Title—Attribute Reference
B-50
Example
R5 is shifted right one position. The MSB retains the old value. It operates
equal to an arithmetic division by 2.
RRA
R5
; R5/2 –> R5
;
The value in R5 is multiplied by 0.75 (0.5 + 0.25).
;
PUSH
R5
; hold R5 temporarily using stack
RRA
R5
; R5
×
0.5 –> R5
ADD
@SP+,R5
; R5
×
0.5 + R5 = 1.5
×
R5 –> R5
RRA
R5
; (1.5
×
R5)
Ч
0.5 = 0.75
Ч
R5 –> R5
......
......
; OR
;
RRA
R5
; R5
×
0.5 –> R5
PUSH
R5
; R5
×
0.5 –> TOS
RRA
@SP
; TOS
Ч
0.5 = 0.5
Ч
R5
Ч
0.5 = 0.25
Ч
R5 –> TOS
ADD
@SP+,R5
; R5
×
0.5 + R5
Ч
0.25 = 0.75
Ч
R5 –> R5
......
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
R5
; R5/2 –> R5: operation is on low byte only
; High byte of R5 is reset
;
The value in R5 (low byte only) is multiplied by 0.75 (0.5 + 0.25).
;
PUSH.B
R5
; hold low byte of R5 temporarily using stack
RRA.B
R5
; R5
×
0.5 –> R5
ADD.B @SP+,R5
;
R5
×
0.5 + R5 = 1.5
×
R5 –> R5
RRA.B
R5
; (1.5
×
R5)
Ч
0.5 = 0.75
Ч
R5 –> R5
......
; OR
;
RRA.B
R5
; R5
×
0.5 –> R5
PUSH.B
R5
; R5
×
0.5 –> TOS
RRA.B
@SP
;TOS
Ч
0.5 = 0.5
Ч
R5
Ч
0.5 = 0.25
Ч
R5 –> TOS
ADD.B
@SP+,R5
; R5
×
0.5 + R5
Ч
0.25 = 0.75
Ч
R5 –> R5
......