SX Users Manual Rev. 3.1
© 2000 Scenix Semiconductor, Inc. All rights reserved.
Chapter 3 Instruction Set
Subtract W from fr
fr = fr - W
C, DC, Z
0000 101f ffff
This instruction subtracts the contents of W from the contents of the specified file
register and writes the 8-bit result into the same file register. W is left unchanged.
The register contents are treated as unsigned values.
If the result of subtraction is negative (W is larger than fr), the C bit is cleared to 0
and the lower eight bits of the result are written to the file register. Otherwise, the
C bit is set to 1.
If there is a borrow from bit 3 to bit 4, the DC (digit carry) bit is cleared to 0.
Otherwise, the bit is set to 1.
If the result of subtraction is 00h, the Z bit is set. Otherwise, the bit is cleared.
If the CF bit in the FUSEX configuration register has been programmed to 0, this
instruction also subtracts the complement of the C bit as a borrow-in input:
fr = fr - W - /C
See Example 2 below for a program example of multiple-byte subtraction with
This example subtracts the contents of W from file register 0Dh. For example, if the
file register contains 35h and W contains 06h, this instruction subtracts 06h from
35h and writes the result, 2Fh, into the file register. It also sets the C bit, clears the
DC bit, and clears the Z bit.
set $03.0 ;set carry bit for no borrow in
mov W,$0A ;load W from 0Ah (low-order byte)
sub $0C,W ;low-order subtraction, C=0 for borrow out
mov W,$0B ;load W from 0Bh (high-order byte)
sub $0D,W ;high-order subtraction, borrow in & out