PIC18CXX2
Subtract WREG from f with
Borrow
Subtract WREG from f with
Borrow (cont’d)
SUBWFB
SUBWFB
SUBWFB REG, 1, 0
Syntax:
[ label ]
Example 1:
SUBWFB f,d,a
Before Instruction
Operands:
0 ≤ f ≤ 255
REG
=
0x19
0x0D
1
(0001 1001)
(0000 1101)
d
a
[0,1]
[0,1]
WREG
C
=
=
Operation:
(f) – (WREG) – (C) → dest
After Instruction
REG
WREG
C
Z
N
=
=
=
=
=
0x0C
0x0D
1
0
0
(0000 1011)
(0000 1101)
Status Affected:
Encoding:
N,OV, C, DC, Z
0101
10da
ffff
ffff
Description:
Subtract WREG and the carry flag
(borrow) from register 'f' (2’s com-
plement method). If 'd' is 0, the
; result is positive
Example2: SUBWFBREG, 0, 0
Before Instruction
result is stored in WREG. If 'd' is
1, the result is stored back in reg-
ister 'f' (default). If ’a’ is 0, the
Access Bank will be selected,
overriding the BSR value. If ’a’ is
1, then the bank will be selected
as per the BSR value (default).
REG
=
0x1B
0x1A
0
(0001 1011)
(0001 1010)
WREG
C
=
=
After Instruction
REG
=
0x1B
0x00
1
1
0
(0001 1011)
WREG
=
C
Z
N
=
=
=
; result is zero
Words:
Cycles:
1
1
Example3: SUBWFBREG, 1, 0
Q Cycle Activity:
Q1
Before Instruction
Q2
Q3
Q4
REG
=
0x03
0x0E
1
(0000 0011)
(0000 1101)
Decode
Read
register ’f’
Process
Data
Write to
destination
WREG
C
=
=
After Instruction
REG
comp]
=
0xF5
(1111 0100) [2’s
WREG
=
0x0E
(0000 1101)
C
Z
N
=
=
=
0
0
1
; result is negative
7/99 Microchip Technology Inc.
Preliminary
DS39026B-page 229