lecture 10 (arithmetic instructions)

25
Microprocessor Application EngineeringInstruction set Instruction set CI 052 02/21/15 K.Rajalakshmi,II!,"oi#a 1 8088/8086 MICROPROCESSOR PROGRAMMING – INTEGER INSTRUCTIONS AND COMPUTATIONS $.1 %ata&!rans'er Instr(ctions $.2 Arithmetic Instr(ctions $.) *ogic Instr(ctions $.+ hi't Instr(ctions $.5 Rotate Instr(ctions

Upload: ayush-purohit

Post on 07-Oct-2015

225 views

Category:

Documents


0 download

DESCRIPTION

5555555555555555555

TRANSCRIPT

02/21/15 K.Rajalakshmi,II!,"oi#a 1
8088/8086 MICROPROCESSOR PROGRAMMING –
02/21/15 K.Rajalakshmi,II!,"oi#a 2
7.1 Arithmetic Instructions
•Data Formats   Unsigned binar btes
  Signed binar btes
02/21/15 K.Rajalakshmi,II!,"oi#a )
ADC  Add bte or !ord !ith carr
INC Increment bte or !ord b 1
AAA  AS$II ad%ust &or addition
DAA Decimal ad%ust &or addition
Subtraction
SBB Subtract bte or !ord !ith borro!
DEC Decrement bte or !ord b 1
NEG 'egate bte or !ord
AAS  AS$II ad%ust &or subtraction
DAS Decimal ad%ust &or subtraction
 Arithmetic Instruction
02/21/15 K.Rajalakshmi,II!,"oi#a +
AAM  AS$II ad%ust &or multipl
Division
AAD  AS$II ad%ust &or division
CBW $onvert bte or !ord
CWD $onvert !ord to double !ord
 
02/21/15 K.Rajalakshmi,II!,"oi#a 5
 
$arr *$F+
 AD$ Add !ith carr AD$ D)S *S+ , *D+ , *$F+  *D+
$arr *$F+
I'$ Increment b 1 I'$ D *D+ , 1 *D+ (F)SF)-F)
 AF)#F
 AAA (F)SF)-F)
DAA (F)SF)-F)
02/21/15 K.Rajalakshmi,II!,"oi#a -
 Allo!ed (perands &or ADD
02/21/15 K.Rajalakshmi,II!,"oi#a $
2AM#3 *1+4
 Assume that the A2 and 52 registers contain 11661/ and
6A5$1/) respectivel. hat is the result o& e8ecuting the
instruction ADD A2) 529
The sum ends up in destination register A2. That is
  *A2+ : 155$1/
02/21/15 K.Rajalakshmi,II!,"oi#a
02/21/15 K.Rajalakshmi,II!,"oi#a
02/21/15 K.Rajalakshmi,II!,"oi#a 10
2AM#3*;+4
The original contents o& A2) 53) !ord<si=e memor location
SUM) and carr &lag *$F+ are 1;>?1/) A51/) 66$D1/) and 61/)
respectivel. Describe the results o& e8ecuting the &ollo!ing
se@uence o& instruction9
 ADD A2) SUMB
 AD$ 53) 6C
 
 
02/21/15 K.Rajalakshmi,II!,"oi#a 11
2AM#3 *>+4
hat is the result o& e8ecuting the &ollo!ing instruction se@uence9
 ADD A3) 53
 AAA
 Assuming that A3 contains >;1/ *AS$II code &or ;+ and 53 contains >?1/ 
*AS$II code ?+) and that A has been cleared.
Solution4
The result a&ter the AAA instruction is
*A3+ : 6/1/
*A+ : 661/
 
02/21/15 K.Rajalakshmi,II!,"oi#a 12
2AM#3 *?+4
#er&orm a >;<bit binar add operation on the contents o& the
processorEs register.
 
02/21/15 K.Rajalakshmi,II!,"oi#a 1)
 
02/21/15 K.Rajalakshmi,II!,"oi#a 1+
 
02/21/15 K.Rajalakshmi,II!,"oi#a 15
EXAMPLE
 Assuming that the contents o& register 52 and $2 are
1;>?1/ and 61;>1/) respectivel) and the carr &lag is 6) !hat
is the result o& e8ecuting the instruction S55 52) $29
Solution:
 : 11111/
 
02/21/15 K.Rajalakshmi,II!,"oi#a 1-
EXAMPLE
 Assuming that the register 52 contains 66>A1/) !hat is the
result o& e8ecuting the &ollo!ing instruction9
' 52
Solution:
: 66661/,FF$/1/
: FF$/1/
Since no carr is generated in this add operation) the carr &lag
is complemented to give
02/21/15 K.Rajalakshmi,II!,"oi#a 1$
2AM#3
#er&orm a >;<bit binar subtraction &or variable 2 and J.
Solution4
M(G A2) SIB H Subtract 3S !ords
SU5 A2) DIB
M(G A2) SIB,; H Subtract MS !ords
S55 A2) DIB,;
 
02/21/15 K.Rajalakshmi,II!,"oi#a 1
 
02/21/15 K.Rajalakshmi,II!,"oi#a 1
 
02/21/15 K.Rajalakshmi,II!,"oi#a 20
2AM#3
The ;Es<complement signed data contents o& A3 are K1 and that o& $3
are K;. hat result is produced in A2 b e8ecuting the &ollo!ing
instruction9
Solution4
8ecuting the MU3 instruction gives
*A2+ : 11111111;811111116;
:1111116166666616; :FD6;1/
*A2+ : <11/ 8 <;1/ : ;1/ : 666;1/
 
02/21/15 K.Rajalakshmi,II!,"oi#a 21
2AM#3
M(G A3) 6A1
*A+ : 11111111; : FF1/ or *A2+ : 1111111116166661;
8ecuting the $D instruction) !e get
*D2+ : 1111111111111111; : FFFF1/
 
02/21/15 K.Rajalakshmi,II!,"oi#a 22
C% an# ACII Arithmetic
C% Arithmetic 3
&&&&&&&
 
02/21/15 K.Rajalakshmi,II!,"oi#a 2)
 
:DAA instruction $unctions on!% &it' A( re)ister
:T'is ""ition must occur ei)'t *its t time
:DAA instruction must come on!% $ter A""ition
instruction+
MO, D-.12 3
:instruction $unctions on!% &it' A( re)ister
:T'is ""ition must occur ei)'t *its t time
:DAS instruction must come on!% $ter
su*trction instruction
subtraction
02/21/15 K.Rajalakshmi,II!,"oi#a 2+
ACII Arithmetic
 
02/21/15 K.Rajalakshmi,II!,"oi#a 25
AAA AAD AAM
ACII a#j(stment a'ter a##ition ACII a#j(stment a'ter %iision ACII a#j(stment a'ter  
M(ltiplication
:Appears a'ter a##ition instr(ction. :Appears 4e'ore #iision instr(ction Appears a'ter m(ltiplication
A%% instr(ction
:A#j(st A> ;ith A%%.
:%ii#e A> ;ith an (npacke# C% n(m4er
:A* ;ill hae ?(otient
:A6 ;ill hae Remin#er 
M@* instr(ction
AAM Instr(ction
0100h<)0)0h = )1)0h
:A#j(st 4 AA% instr(ction
:A> ;ill hae 00+
:00+ is 4inar eF(ialent o' $2 #ecimal
!o get ACII co#e
0205h < )0)0h = )2)5h