Академический Документы
Профессиональный Документы
Культура Документы
instructions
Logic
AND
AND
OR
OR
XOR
XOR
Complement
Complement
Rotate
Rotate
swapping
swapping
affect bit Z
affects bit C
does not affect any
ANDWF f,d
f,d
ANDWF
ANDWF
Syntax:: [[ label
label ]]
Operands: 0 f 127
d [0,1]
f,d
(W) . (f) (
Operation:
destination
Description: And
And the
the contents
contents of
of the
the W
W register
register
with
with register
register f.
f. If
If d
d is
is 0,
0, the
the
result
result is
is stored
stored in
in the
the W
W register.
register. If
If
d
d is
is 1,
1, the
the result
result is
is stored
stored back
back
in
in register
register f.
f.
prepared by : Maher AL-Omari
ANDLW kk
ANDLW
ANDLW
Syntax::
Operands: 0 k 255
Operation:
[[ label
label ]]
(W) . k (W)
Description: And
And the
the contents
contents of
of the
the W
W register
register
with
with k.
k. the
the result
result is
is stored
stored in
in the
the W
W register.
register.
Bit masking
masking
Bit
w=A5h
ANDLW 3f
W=25h
D7
D6
D5
D4
D3
D2
D1
D0
0
0
0
0
( Z = 0, )
1
1
1
0
1
1
IORWF f,d
f,d
IORWF
IORWF
Syntax:: [[ label
label ]]
Operands: 0 f 127
d [0,1]
(W)
f,d
(f) (
Operation:
OR
destination
Description: OR
OR the
the contents
contents of
of the
the W
W register
register with
with register
register f.
f.
If
If d
d is
is 0,
0, the
the result
result is
is stored
stored in
in the
the W
W register.
register. If
If d
d is
is 1,
1, the
the
result
result is
is stored
stored back
back in
in register
register f.
f.
IORLW
IORLW
kk
IORLW
Syntax::
Operands: 0 k 255
Operation:
[[ label
label ]]
(W) OR k (W)
Description: OR
OR the
the contents
contents of
of the
the W
W register
register
with
with register
register k.
k. The
The result
result is
is stored
stored in
in the
the W
W
register.
register.
LogicalOR-ing
OR-ingis
isused
usedto
toset
set selected
selectedbits
bits
Logical
D3 D2
W=E3
IORLW 0C
EFH
(Z = 0,)
prepared by : Maher AL-Omari
XORWF f,d
f,d
XORWF
XORWF
Syntax:: [[ label
label ]]
Operands: 0 f 127
d [0,1]
(W) x
f,d
(f) (
Operation:
OR
destination
Description: XOR
XOR the
the contents
contents of
of the
the W
W register
register
with
with register
register f.
f. If
If d
d is
is 0,
0, the
the
result
result is
is stored
stored in
in the
the W
W register.
register. If
If
d
d is
is 1,
1, the
the result
result is
is stored
stored back
back
in
in register
register f.
f.
prepared by : Maher AL-Omari
XORLW kk
XORLW
XORLW
Syntax::
Operands: 0 k 255
Operation:
[[ label
label ]]
Description: XXOR
OR the
the contents
contents of
of the
the W
W register
register
with
with register
register k.
k. The
The result
result is
is stored
stored in
in the
the W
W
register.
register.
Complementing certain
certain bits
bits
Complementing
w=A5h
XORLW C0
W=65h
D7
D6
D5
D4
D3
D2
D1
D0
1
0
( Z = 0, )
0
0
0
1
Increment W:
addlw 0xff
Decrement W:
xorlw 0xff
xorlw 0xff
addlw 1
2-complement for W:
andlw 0xf0
Mask bits 3, 2, 1, 0:
iorlw 0x0f
Set 3, 2, 1,0:
prepared by : Maher AL-Omari
reg1,0
reg1,0
0xff
0xff
0x01
0x01
reg2,0
reg2,0
reg3
reg3
Reg3=reg2-reg1
COMF
COMF
f,d
f,d
COMF
Syntax::
Operands: 0 f 127
[[ label
label ]]
f,d
dd
[0,1]
[0,1]
0,
0, the
the result
result is
is stored
stored in
in W.
W. If
If d
d is
is 1,the
1,the result
result is
is stored
stored back
back
in
in register
register f
f
RLF
RLF
f,d
f,d
RLF
Syntax::
Operands: 0 f 127
[[ label
label ]]
f,d
dd
[0,1]
[0,1]
C
D7
D0
Operation:
Status Affected: c
Description: The
The contents
contents of
of register
register f
f are
are rotated
rotated one
one bit
bit to
to the
the
left
left through
through the
the Carry
Carry flag.
flag. If
If d
d is
is 0,
0, the
the
result
result is
is placed
placed in
in the
the W
W register.
register. If
If d
d is
is 1,
1, the
the result
result is
is placed
placed
back
back in
in register
register f
f
prepared by : Maher AL-Omari
0X0F
0X0F
REG2,1
REG2,1
REG2,1
REG2,1
REG2,0
REG2,0
0X07
0X07
REG2=d12 , W=d31
RRF f,d
f,d
RRF
RRF
Syntax::
Operands: 0 f 127
[[ label
label ]]
dd
[0,1]
[0,1]
f,d
C
D7
D0
Operation:
Status Affected: c
Description: The
The contents
contents of
of register
register f
f are
are rotated
rotated one
one bit
bit to
to the
the
right
right through
through the
the Carry
Carry flag.
flag. If
If d
d is
is 0,
0, the
the
result
result is
is placed
placed in
in the
the W
W register.
register. If
If d
d is
is 1,
1, the
the result
result is
is placed
placed
back
back in
in register
register f
f
prepared by : Maher AL-Omari
Example 22
Example
reg2
C=0
0X36
Reg1=
0x36
0x36
NA
andlw 0x0F
0X06
0x36
NA
movwf reg2
0X06
0x36
0X06
rlf
0X06
0x36
0x0C
movf
reg1,0
reg2,0
SWAPF
SWAPF
f,d
f,d
SWAPF
Syntax::
Operands: 0 f 127
[[ label
label ]]
f,d
dd
[0,1]
[0,1]
Operation: (f<3:0>)
(f<3:0>)
(destination<7:4>),
(destination<7:4>),
D7
0 0 1 0 1 1 0
D0
1
(f<7:4>)
(f<7:4>)
(destination<3:0>)
(destination<3:0>)
exchanged.
exchanged. If
If d
d is
is 0,
0, the
the result
result is
is placed
placed in
in the
the W
W register.
register. If
If d
d
is
is 1,
1, the
the result
result is
is placed
placed in
in register
register f.
f.
prepared by : Maher AL-Omari
Logic instructions
instructions
Logic
Mnemonic
Mnemonic
Operation
Operation
Affects
Affects
andwf f,f,dd
andwf
Andlw kk
Andlw
iorwf f,f,dd
iorwf
iorlw kk
iorlw
xorwf f,f,dd
xorwf
xorlw kk
xorlw
rlf f,f,dd
rlf
rrf f,f,dd
rrf
comf f,f,dd
comf
swapf f,f,dd
swapf
andW
W ==>>dd
ffand
andW
W ==>>W
W
kkand
orW
W ==>>dd
ffor
orW
W ==>>W
W
kkor
xorW
W==>>dd
ffxor
xorW
W ==>>W
W
kkxor
rotateffleft
leftthrough
throughCC==>>dd
rotate
rotateffright
rightthrough
throughCC==>>dd
rotate
#f==>>dd
#f
fL
fH
fH==>>dd
fL
ZZ
ZZ
ZZ
ZZ
ZZ
ZZ
CC
CC
ZZ