PIC16C55X
SUBWF
Syntax:
Operands:
Operation:
Status
Affected:
Encoding:
Description:
Words:
Cycles:
Example 1:
Example 2:
Example 3:
Subtract W from f
[ label ] SUBWF f,d
0 ≤ f ≤ 127
d ∈ [0,1]
(f) - (W) → (dest)
C, DC, Z
00
0010 dfff ffff
Subtract (2’s complement method)
W register from register 'f'. If 'd' is 0 the
result is stored in the W register. If 'd' is 1
the result is stored back in register 'f'.
1
1
SUBWF REG1,1
Before Instruction
REG1 = 3
W =2
C
=?
After Instruction
REG1 =
W=
C
=
1
2
1; result is positive
Before Instruction
REG1 = 2
W =2
C
=?
After Instruction
REG1 =
W=
C
=
0
2
1; result is zero
Before Instruction
REG1 = 1
W =2
C
=?
After Instruction
REG1 =
W=
C
=
0xFF
2
0; result is negative
SWAPF
Syntax:
Operands:
Operation:
Status Affected:
Encoding:
Description:
Words:
Cycles:
Example
Swap Nibbles in f
[ label ] SWAPF f,d
0 ≤ f ≤ 127
d ∈ [0,1]
(f<3:0>) → (dest<7:4>),
(f<7:4>) → (dest<3:0>)
None
00
1110 dfff ffff
The upper and lower nibbles of
register 'f' are exchanged. If 'd' is 0
the result is placed in W register. If 'd'
is 1 the result is placed in register 'f'.
1
1
SWAPF REG, 0
Before Instruction
REG1 = 0xA5
After Instruction
REG1 = 0xA5
W
= 0x5A
TRIS
Syntax:
Operands:
Operation:
Status Affected:
Encoding:
Description:
Words:
Cycles:
Example
Load TRIS Register
[ label ] TRIS f
5≤f≤7
(W) → TRIS register f;
None
00
0000 0110 0fff
The instruction is supported for code
compatibility with the PIC16C5X
products. Since TRIS registers are
readable and writable, the user can
directly address them.
1
1
To maintain upward compatibility
with future PICmicro™ products, do
not use this instruction.
DS40143D-page 64
Preliminary
2002 Microchip Technology Inc.