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/