Atmel Xplained Pro Evaluation Kit ATSAM4E-XPRO ATSAM4E-XPRO Data Sheet

Product codes
ATSAM4E-XPRO
Page of 1506
129
SAM4E [DATASHEET]
Atmel-11157D-ATARM-SAM4E16-SAM4E8-Datasheet_12-Jun-14
12.6.5.19  UHASX and UHSAX
Unsigned Halving Add and Subtract with Exchange and Unsigned Halving Subtract and Add with Exchange.
Syntax
op{cond} {Rd}, RnRm
where:
op
is one of:
UHASX Add and Subtract with Exchange and Halving.
UHSAX Subtract and Add with Exchange and Halving.
cond
is an optional condition code, see 
.
Rd
is the destination register.
Rn, Rm
are registers holding the first and second operands.
Operation
The UHASX instruction:
1.
Adds the top halfword of the first operand with the bottom halfword of the second operand.
2.
Shifts the result by one bit to the right causing a divide by two, or halving.
3.
Writes the halfword result of the addition to the top halfword of the destination register. 
4.
Subtracts the top halfword of the second operand from the bottom highword of the first operand.
5.
Shifts the result by one bit to the right causing a divide by two, or halving.
6.
Writes the halfword result of the division in the bottom halfword of the destination register.
The UHSAX instruction:
1.
Subtracts the bottom halfword of the second operand from the top highword of the first operand.
2.
Shifts the result by one bit to the right causing a divide by two, or halving.
3.
Writes the halfword result of the subtraction in the top halfword of the destination register.
4.
Adds the bottom halfword of the first operand with the top halfword of the second operand.
5.
Shifts the result by one bit to the right causing a divide by two, or halving.
6.
Writes the halfword result of the addition to the bottom halfword of the destination register.
Restrictions
Do not use SP and do not use PC
.
Condition Flags
These instructions do not affect the condition code flags.
Examples
UHASX
R7, R4, R2 ; Adds top halfword of R4 with bottom halfword of R2
; and writes halved result to top halfword of R7
; Subtracts top halfword of R2 from bottom halfword of
; R7 and writes halved result to bottom halfword of R7
UHSAX
R0, R3, R5 ; Subtracts bottom halfword of R5 from top halfword of
 ; R3 and writes halved result to top halfword of R0
 ; Adds top halfword of R5 to bottom halfword of R3 and
; writes halved result to bottom halfword of R0.