lecture 11 (logicalinstructions)
TRANSCRIPT
-
7/21/2019 Lecture 11 (LogicalInstructions)
1/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 1
Logic Instructions
The logic instructions include
AND
OR
XOR (Exclusive-OR)
NOT
TEST
-
7/21/2019 Lecture 11 (LogicalInstructions)
2/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 2
Alloed o!er"nds #or AND$ OR$ "nd
XOR instructions
Alloed o!er"nds #or NOT instruction
Logic instructions % AND$ OR$ XOR$ NOT
-
7/21/2019 Lecture 11 (LogicalInstructions)
3/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 3
EXA&'LE
Descrie the results o# executing the #olloing instructions
&O* AL$ +,+,+,+,
AND AL$ +++,,,,,
OR AL$ ,,++++++
XOR AL$ ++++,,,,
NOT ALSolution%
Executing the AND instruction$ e get
(AL).+,+,+,+,/ +++,,,,,/. +++,+,+,/.,0,1Executing the OR instruction$ e get
(AL). +++,+,+,/2 ,,++++++/. ,,+,+,+,/.D0,1
Executing the XOR instruction$ e get
(AL). ,,+,+,+,/ ++++,,,,/. ,,+,,+,+/.DA,1Executing the NOT instruction$ e get
(AL). (NOT),,+,,+,+/. ++,++,+,/./0,1
-
7/21/2019 Lecture 11 (LogicalInstructions)
4/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 4
EXA&'LE
Masking and setting bits in a register.
&"s3 o# the u!!er ,/ its o# the ord o# d"t" in AX
AND AX$ +++4,1
&O* AL$ 56ONTROL74LA8S9
OR AL$ ,+:
&O* 56ONTROL74LA8S9$ AL
(AL).XXXXXXXX/2+++,++++/. XXX,XXXX/
Setting ; o# the
-
7/21/2019 Lecture 11 (LogicalInstructions)
5/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 5
TEST inst!"tion #$%oms th$ &N' o#$ation
TEST do$sn(t "han)$ th$ d$stination o#$and. E%%$"ts onl* th$ %la) $)ist$
Sam$ add$ssin) mod$ as &N'
TEST %!n"tions sam$ as +- !t t$st onl* a
sin)l$ it.
-
7/21/2019 Lecture 11 (LogicalInstructions)
6/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida
-
7/21/2019 Lecture 11 (LogicalInstructions)
7/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida
Shi#t instructions% S:L$ S:R$ SAL$ SAR
Alloed o!er"nds #or shi#t instructions
-
7/21/2019 Lecture 11 (LogicalInstructions)
8/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida
0010110001001000
0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 00
it 0
0&
&%t$
&
$%o$
+
Result of executing SHL AX,1
it 0it 15
it 15
Result of executing SHR AX,1
0010110001001000
0 0 0 1 0 0 1 0 0 0 1 1 0 1 0 0
it 0
0
&
$%o$
0
+
it 0
it 15
it 15
-
7/21/2019 Lecture 11 (LogicalInstructions)
9/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida
EXA&'LE
Assu=e th"t 6L cont"ins +/,1 "nd AX cont"ins +>,A,1?
Deter=ine the ne contents o# AX "nd the c"rr< #l"g "#ter
the instruction SAR AX$ 6L is executed?
Solution%
(AX).++++++,++,+++,,+/.+/;1,1
"nd the c"rr< #l"g is (64).,/
-
7/21/2019 Lecture 11 (LogicalInstructions)
10/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 10
SAR AX,CL
0101100010010000
0 0 0 0 0 0 1 0 0 1 0 0 0 1 1 0
it 0
&
$%o$
1
+
it 0
it 15
it 15
&
&%t$
MOV CL,02H
-
7/21/2019 Lecture 11 (LogicalInstructions)
11/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 11
EXA&'LE
Isol"te the it @ o# the
-
7/21/2019 Lecture 11 (LogicalInstructions)
12/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 12
-
7/21/2019 Lecture 11 (LogicalInstructions)
13/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 13
-
7/21/2019 Lecture 11 (LogicalInstructions)
14/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 14
0010110001001000
0 0 1 0 0 1 0 0 0 1 1 0 1 0 0 0Bit 0
0
AX
After
AX
Before
CF
Result of executing ROL AX,1
Bit 0Bit 1
Bit 1
0
CF
-
7/21/2019 Lecture 11 (LogicalInstructions)
15/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 15
AX
After
AX
Before
Result of executing ROR AX,CL !it" #CL$%&
0010110001001000
Bit 0
0
CF
Bit 0Bit 1
Bit 1
0
CF
0 1 0 0 0 0 0 1 0 0 1 0 0 0 1 1
-
7/21/2019 Lecture 11 (LogicalInstructions)
16/17
Instruction setInstruction set
02/21/15 K.Rajalakshmi,JIIT,Noida 1
Bit 1 Bit 0CF
Rotation "a!s$d * $6$"!tion o% th$ R+7 inst!"tion
-
7/21/2019 Lecture 11 (LogicalInstructions)
17/17
Instruction setInstruction set
02/21/15 K Rajalakshmi JIIT Noida
EXA&'LE
Bh"t is the result in X "nd 64 "#ter execution o# the #olloing
instructions
R6R X$ 6L
Assu=e th"t$ !rior to execution o# the instruction$ (6L).+;,1$
(X).,/@;,1$ "nd (64).+Solution%
The origin"l contents o# X "re
(X) . +++,++,+++,,+,++/ . ,/@;,1
Execution o# the R6R co=="nd c"uses " ;-it rot"te right
through c"rr< to t"3e !l"ce on the d"t" in X$ the results "re
(X) . ,++++++,++,+++,,/. C,/@,1 (64) . +/