PIC18CXX2
SUBFWB
SUBLW
Subtract WREG from literal
SUBFWB
REG, 1, 0
Example 1:
Syntax:
[ label ]
SUBLW k
Before Instruction
Operands:
Operation:
0 ≤ k ≤ 255
REG
WREG
C
=
=
=
3
2
1
k – (WREG) → WREG
N,OV, C, DC, Z
Status Affected:
Encoding:
After Instruction
REG
WREG
C
Z
N
=
=
=
=
=
FF
2
0
0
1
0000
1000
kkkk
kkkk
Description:
WREG is subtracted from the
eight bit literal 'k'. The result is
placed in WREG.
; result is negative
REG, 0, 0
SUBFWB
Example 2:
Words:
Cycles:
1
1
Before Instruction
REG
WREG
C
=
=
=
2
5
1
Q Cycle Activity:
Q1
Q2
Q3
Q4
Decode
Read
literal ’k’
Process
Data
Write to
WREG
After Instruction
REG
=
2
3
1
0
0
WREG
=
SUBLW 0x02
Example 1:
C
Z
N
=
=
=
Before Instruction
; result is positive
REG, 1, 0
WREG
C
=
=
1
?
SUBFWB
Example 3:
After Instruction
Before Instruction
REG
=
1
WREG
=
1
WREG
C
=
=
2
0
C
Z
N
=
=
=
1
0
0
; result is positive
After Instruction
REG
WREG
=
=
0
2
SUBLW 0x02
Example 2:
C
Z
N
=
=
=
1
1
0
Before Instruction
; result is zero
WREG
C
=
=
2
?
After Instruction
WREG
=
0
C
Z
N
=
=
=
1
1
0
; result is zero
SUBLW 0x02
Example 3:
Before Instruction
WREG
C
=
=
3
?
After Instruction
WREG
=
FF
; (2’s complement)
; result is negative
C
Z
N
=
=
=
0
0
1
7/99 Microchip Technology Inc.
Preliminary
DS39026B-page 227