PIC18F010/020
SUBWFB
Syntax:
Subtract WREG from f with
Borrow
[ label ] SUBWFB f [ ,d [,a] ]
Operands:
0 ≤ f ≤ 255
d ∈ [0,1]
a ∈ [0,1]
Operation:
(f) – (WREG) – (C) → dest
Status Affected: N,OV, C, DC, Z
Encoding:
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 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, the Bank will be selected as per
the BSR value.
Words:
1
Cycles:
1
Q Cycle Activity:
Q1
Q2
Q3
Q4
Decode
Read
register ’f’
Process
Data
Write to
destination
SUBWFB
Example 1:
Subtract WREG from f with
Borrow (cont’d)
SUBWFB REG
Before Instruction
REG = 0x19
WREG = 0x0D
C
=1
(0001 1001)
(0000 1101)
After Instruction
REG =
WREG =
C
=
Z
=
N
=
0x0C
0x0D
1
0
0
(0000 1011)
(0000 1101)
; result is positive
Example 2:
SUBWFB REG, W
Before Instruction
REG = 0x1B
WREG = 0x1A
C
=0
(0001 1011)
(0001 1010)
After Instruction
REG =
WREG =
C
=
Z
=
N
=
0x1B
0x00
1
1
0
(0001 1011)
; result is zero
Example 3:
SUBWFB REG
Before Instruction
REG = 0x03
WREG = 0x0E
C
=1
(0000 0011)
(0000 1101)
After Instruction
REG =
WREG =
C
=
Z
=
N
=
0xF5
0x0E
0
0
1
(1111 0100) [2’s comp]
(0000 1101)
; result is negative
2001 Microchip Technology Inc.
Preliminary
DS41142A-page 133