|
PIC16F627A_09 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 PIC® MCU
products, do not use this
instruction.
© 2009 Microchip Technology Inc.
DS40044G-page 129
|
▷ |