![](http://datasheet.mmic.net.cn/380000/-PD784928Y_datasheet_16744934/-PD784928Y_338.png)
338
CHAPTER 7 DESCRIPTION OF INSTRUCTIONS
Subtract, Absolute and Accumulate Word
Correlation Instruction
[Instruction format]
SACW [TDE +], [WHL +]
[Operation]
AX
←
| (TDE) – (WHL) | + AX, TDE
←
TDE + 2, WHL
←
WHL + 2, C
←
C – 1, end if
(C = 0 or CY = 1)
[Operands]
Mnemonic
Operands ($addr16)
SACW
[TDE +], [WHL +]
[Flags]
S
Z
AC
P/V
CY
×
×
×
×
×
[Description]
Subtraction is performed on the 16-bit data items addressed by the TDE register and WHL register, the absolute
value of the result is added to the contents of the AX register, and the result is stored in the AX register.
Each time the above operation is performed, the contents of the TDE and WHL registers are incremented by
2, and the contents of the C register are decremented by 1.
The above operations are repeated until the C register value is 0 or a carry is generated out of bit 15 as a result
of the addition.
If a carry occurs from bit 15 as a result of addition, therefore stopping repetition, the TDE and WHL registers
retain the values immediately before the carry has occurred plus 2. The C register retains the value immediately
before the carry has occurred.
If an interrupt or macro service request that can be acknowledged during execution of the SACW instruction
is generated, the interrupt or macro service processing is performed before the series of operation processing.
When an interrupt is acknowledged, the program counter (PC) value saved to the stack is the SACW instruction
start address.
Therefore, after returning from the interrupt, continuation of the interrupted SACW instruction is executed.
The CY flag is set (1) if a carry is generated out of bit 15 as a result of the final addition, and cleared (0) otherwise.
The contents of the S, Z, AC, and P/V flags are undefined.
The SACW instruction does not clear the contents of the AX register pair automatically, and therefore this should
be done by the program if necessary.
SACW