English
Language : 

PIC16F627A_05 Datasheet, PDF (129/180 Pages) Microchip Technology – Flash-Based, 8-Bit CMOS Microcontrollers with nanoWatt Technology
PIC16F627A/628A/648A
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 = 1
W =2
C = 1; result is positive
DC = 1
Z =0
Before Instruction
REG1 = 2
W =2
C =?
After Instruction
REG1 = 0
W =2
C = 1; result is zero
Z = DC = 1
Before Instruction
REG1 = 1
W =2
C =?
After Instruction
REG1 = 0xFF
W =2
C = 0; result is negative
Z = DC = 0
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 REG1, 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 compatibil-
ity with future PICmicro® MCU
products, do not use this
instruction.
© 2005 Microchip Technology Inc.
DS40044D-page 127