SlideShare a Scribd company logo
ASCII ADJUST AND
DECIMAL ADJUST




                   1
INSTRUCTIONS
   AAA - ASCII Adjust After Addition
   AAS - ASCII Adjust After Subtraction
   AAM - ASCII Adjust After Multiply
   AAD - ASCII Adjust Before Division
   DAA - Decimal Adjust for Addition
   DAS - Decimal Adjust for Subtraction



                                           2
INTRODUCTION
The PC supports BCD format,
Uses of BCD
   1)No loss of precision
   2)Simpler to perform arithmetic
   operation on small values from keyboard
BCD can be stored in two way:
   Unpacked BCD
   Packed BCD
                                             3
Unpacked BCD Data
Unpacked BCD representation contains only
One decimal digit per byte. The digit is
stored in the least significant 4 bits; the
most significant 4 bits are not relevant to
the value of the represented number.

Example: Representing 1527
              01 05 02 07h

                                              4
Packed BCD Data
Packed BCD representation packs two
Decimal digits into a single byte.

Example: Representing 1527
                   15 27h




                                      5
ASCII Adjust After Addition
  Adjusts the result of the addition of two
unpacked BCD values to create a unpacked
BCD result.

Operation 1:
In AL
If rightmost nibble is >9 (ie)A to F
         Or AuxilaryFlag=1
ADD 6 to rightmost nibble
                                              6
Operation 2:
Clear left nibble form AL.

Operation 3:
In AH
ADD 1

Operation 4:
Set Carry and AuxilaryCarry
                              7
.model small
.data
   b1 dw 38h
   b2 dw 34h
.code
   mov ax,@data
   mov ds,ax
   mov ax,b1   ;moving unpacked BCD into ax
   mov bx,b2   ;moving unpacked BCD into bx
   add ax,bx
   aaa         ;adjusting unpacked BCD after addition
   or ax,3030h
   end


                                                        8
ASCII Adjust After Subtraction
  Adjusts the result of the subtraction of two
unpacked BCD values to create a unpacked BCD
result.

Operation 1:
  a)AAS checks the rightmost nibble in AL
  b)If rightmost nibble is >9 (ie)A to F
         Or AuxilaryFlag=1
  c)Then Subtract 6 from rightmost nibble

                                                 9
Operation 2:
Clear left nibble in AL.

Operation 3:
Subtracts 1 from AH

Operation 4:
Set Carry and AuxilaryCarry

                              10
Example :
d1 contains 34h , d2 contains 38h of byte
  type
                  Ax            AF
Mov AL, d1 ;        0034
Sub AL, d2;           00fc           1
AAS ;               ff06            1
  since the rightmost digit of AL is c ,
  subtract 6 from AL
 Subtract 1 from ah, set AF and CF flags

 The answer is -4, is ff06 in 10’s

  complement                                11
.model small
.data
b1 dw 38h
b2 dw 34h
.code
mov ax,@data
mov ds,ax
mov ax,b1      ;moving unpacked BCD into ax
mov bx,b2      ;moving unpacked BCD into bx
sub ax,bx
aas            ;adjusting unpacked BCD after subtraction
or ax,3030h
end


                                                           12
ASCII Adjust After Multiplication
    For multiplication and Division of ASCII
    numbers require that the numbers first be
    converted into unpacked BCD format.
    Before Multiplication First clear the leftmost
    nibble in each Byte.
   After Multiplication
   AAM performs the following operations
        1) Divides AL value by 10 (0AH)
        2) Stores Quotient in AH
        3) Store Remainder in AL
                                                      13
Example:
AL contains 35H and CL contains 39H
Instruction    comment          AX     CL
and CL, 0Fh; Convert CL to 09    0035 39
and AL,0Fh; Convert AL to 05     0005 09
mul CL;      Multiply AL by CL   002D
AAM ;        Convert to unpacked 0405
              BCD
Or AX,3030h; covert to ASCII      3435


                                            14
   Mul operation generates 45 (002Dh) in
    AX

   AAM divides this value by 10, so quotient
    of 04 in AH and remainder of 05 in AL

   OR instruction converts the unpacked
    BCD to
    ASCII format
                                                15
.model small
.data
b1 dw 39h ; 9 in ASCII Format
b2 dw 35h ; 5 in ASCII Format
.code
mov ax,@data
mov ds,ax
mov ax,b1 ;AX=0039h
and AL,0fh ;AX=0009h
mov bx,b2 ;BX=0035h
and bl,0fh ;BX=0005h
mul bx      ;AX=002Dh
aam
or ax,3030h
end

                                16
ASCII Adjust Before Division
   AAD allows for a 2-Byte Dividend in AX. The
    divisor can be only a single Byte(0-9)
    Before Division First clear the leftmost nibble in
    each Byte.
   Operations done by AAD instruction
           1) AAD multiplies the AH by 10(0Ah).
           2) Then adds the product to AL and clears
    the AH
   After AAD , division is performed.


                                                          17
Example:
AX contains 3238 (28) - Dividend
CL contains 37 (07) – Divisor
Instruction      comment             AX   CL
and CL,0Fh;     convert to unpacked 3238 07
                 BCD
and AX,0F0Fh; convert to unpacked 0208 07
                 BCD
AAD;             convert to binary  001C
div CL;          divide by 7        0004

                                               18
   AAD multiplies the AH by 10(0Ah)
   Adds the product 20(14h) to the AL and
    clears
     the AH
    The result is 001Ch, is hex
    representation of decimal 28
    Then division is performed.
    Remainder stored in AH, Quotient stored
    in AL

                                               19
model small
.data
b1 dw 3238h ; 28 in ASCII Format
b2 db 37h ; 7 in ASCII Format
.code
mov ax,@data
mov ds,ax
mov ax,b1 ;AX=3238h
and ax,0f0fh ;AX=0208h
mov cl,b2 ;CL=37h
and cl,0fh ;CL=07h
aad ; AX= 001c
div cl ; AX=0004
or ax,3030h; AX=3034
end

                                   20
Decimal Adjust
  To adjust the result of packed BCD
numbers which stored in AL.

DAA - Decimal Adjust for Addition
DAS - Decimal Adjust for Subtraction




                                       21
Decimal Adjust for Addition
DAA performs the following operations:
 Operation 1:
If AL is >9 (ie) A to F
 or AuxilaryCarry=1 then
ADD 6 to AL
Set AuxilaryCarry=1


                                         22
Operation 2:
If AL contains value > 99
    or Carry=1 then
ADD 60 to AL and set Carry =1

   Otherwise
AuxilaryCarry=0 ,carry=0

                                23
AL contains   45h
BL contains   45h
Instruction   Comment             AL
ADD AL,BL     ; AL=AL+BL             8Ah
DAA           ; Adjust packed BCD   90h
                addition


                                           24
   DAA checks the rightmost nibble of AL, it
    is A so add 6 to AL
    Now AL = 90




                                                25
.model small
.data
    d1 dw 45h ;moving 45 as packed BCD
    d2 dw 45h ;moving 45 as packed BCD
.code
    mov ax,@data
    mov ds,ax
    mov ax,d1
    mov bx,d2
    add ax,bx
    daa       ;adjusting the packed BCD after addition
    end




                                                         26
Decimal Adjust for Subtraction
Operations performed by DAS :
If AL is >9 (ie) A to F
      or AuxilaryCarry=1 then
Subtract 6 from AL
Set Carry=1

Otherwise
AuxilaryCarry=0 ,carry=0


                                  27
AL contains 80h
BL contains 49h
Instruction  Comment            AL
SUB AL,BL ; AL=AL-BL               37h
DAS           ; Adjust packed BCD   31h
              Subtraction


                                      28
.model small
.data
    d1 dw 57h
    d2 dw 48h
.code
    mov ax,@data
    mov ds,ax
    mov ax,d1 ;moving 45 as packed BCD
    mov bx,d2 ;moving 45 as packed BCD
    sub ax,bx
    das       ; adjusting the packed BCD after subraction
    end



                                                            29
THANK U


          30

More Related Content

What's hot (20)

PPTX
Carry look ahead adder
dragonpradeep
 
PPTX
Addressing modes of 8086
saurav kumar
 
PPTX
Decoders-Digital Electronics
Paurav Shah
 
PPTX
MEDIUM ACCESS CONTROL
junnubabu
 
PPTX
Stacks & subroutines 1
deval patel
 
PPTX
AMBA AHB 5
SUNODH GARLAPATI
 
PPTX
Counters & time delay
Hemant Chetwani
 
PPTX
Multiplexing in mobile computing
ZituSahu
 
PDF
Memory segmentation-of-8086
mudulin
 
PDF
Types of line coding
ramalakshmi54
 
PPT
Computer architecture pipelining
Mazin Alwaaly
 
PPTX
BCH Codes
AakankshaR
 
PPTX
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
PPTX
Instruction set of 8086
9840596838
 
PPTX
Presentation on 8086 Microprocessor
Nahian Ahmed
 
PPTX
Computer Memory Hierarchy Computer Architecture
Haris456
 
PPTX
Addressing modes of 8086 - Binu Joy
Binu Joy
 
PPT
Chapter 03 cyclic codes
Manoj Krishna Yadavalli
 
PDF
Stack and subroutine
milandhara
 
PPTX
Flow control instructions
Prodip Ghosh
 
Carry look ahead adder
dragonpradeep
 
Addressing modes of 8086
saurav kumar
 
Decoders-Digital Electronics
Paurav Shah
 
MEDIUM ACCESS CONTROL
junnubabu
 
Stacks & subroutines 1
deval patel
 
AMBA AHB 5
SUNODH GARLAPATI
 
Counters & time delay
Hemant Chetwani
 
Multiplexing in mobile computing
ZituSahu
 
Memory segmentation-of-8086
mudulin
 
Types of line coding
ramalakshmi54
 
Computer architecture pipelining
Mazin Alwaaly
 
BCH Codes
AakankshaR
 
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
Instruction set of 8086
9840596838
 
Presentation on 8086 Microprocessor
Nahian Ahmed
 
Computer Memory Hierarchy Computer Architecture
Haris456
 
Addressing modes of 8086 - Binu Joy
Binu Joy
 
Chapter 03 cyclic codes
Manoj Krishna Yadavalli
 
Stack and subroutine
milandhara
 
Flow control instructions
Prodip Ghosh
 

Similar to Ascii adjust & decimal adjust (20)

PPTX
Bcd and ascii arithmetic instructions
Dr. Girish GS
 
PPTX
Ascii arithmetic instructions
Dr. Girish GS
 
PPTX
Bcd arithmetic instructions
Dr. Girish GS
 
PPTX
Module 2 (1).pptx
Dr. Thippeswamy S.
 
PPTX
Mod-2.pptx
Dr. Thippeswamy S.
 
PPT
Al2ed chapter11
Abdullelah Al-Fahad
 
PPT
Instruction set of 8086
Tirumalesh Nizampatnam
 
PPTX
Instruction 4.pptx
HebaEng
 
DOCX
Notes aaa aa
HarshitParkar6677
 
PPT
86 pr0grams
Thiagarajan Govindasamy
 
PDF
Assembly language 8086
John Cutajar
 
PDF
Assembly language 8086 intermediate
John Cutajar
 
PPT
Arithmetic & logical operations in 8051
Jay Patel
 
PDF
8086 instructions
Ravi Anand
 
DOCX
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
COMSATS Abbottabad
 
PDF
6 arithmetic logic inst and prog
Channabasappa Kudarihal
 
PDF
Coal 17 - arithematic operation in Assembly Programming
Muhammad Taqi Hassan Bukhari
 
PPT
Chp2 introduction to the 68000 microprocessor copy
mkazree
 
DOCX
Introduction to instruction set. new course
Samee Ur Rehman
 
PDF
Taller Ensambladores
Christian Morales
 
Bcd and ascii arithmetic instructions
Dr. Girish GS
 
Ascii arithmetic instructions
Dr. Girish GS
 
Bcd arithmetic instructions
Dr. Girish GS
 
Module 2 (1).pptx
Dr. Thippeswamy S.
 
Mod-2.pptx
Dr. Thippeswamy S.
 
Al2ed chapter11
Abdullelah Al-Fahad
 
Instruction set of 8086
Tirumalesh Nizampatnam
 
Instruction 4.pptx
HebaEng
 
Notes aaa aa
HarshitParkar6677
 
Assembly language 8086
John Cutajar
 
Assembly language 8086 intermediate
John Cutajar
 
Arithmetic & logical operations in 8051
Jay Patel
 
8086 instructions
Ravi Anand
 
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
COMSATS Abbottabad
 
6 arithmetic logic inst and prog
Channabasappa Kudarihal
 
Coal 17 - arithematic operation in Assembly Programming
Muhammad Taqi Hassan Bukhari
 
Chp2 introduction to the 68000 microprocessor copy
mkazree
 
Introduction to instruction set. new course
Samee Ur Rehman
 
Taller Ensambladores
Christian Morales
 
Ad

More from Tech_MX (20)

PPTX
Virtual base class
Tech_MX
 
PPTX
Uid
Tech_MX
 
PPTX
Theory of estimation
Tech_MX
 
PPTX
Templates in C++
Tech_MX
 
PPT
String & its application
Tech_MX
 
PPTX
Statistical quality__control_2
Tech_MX
 
PPTX
Stack data structure
Tech_MX
 
PPT
Stack Data Structure & It's Application
Tech_MX
 
PPTX
Spss
Tech_MX
 
PPTX
Spanning trees & applications
Tech_MX
 
PPTX
Set data structure 2
Tech_MX
 
PPTX
Set data structure
Tech_MX
 
PPTX
Real time Operating System
Tech_MX
 
PPTX
Parsing
Tech_MX
 
PPTX
Mouse interrupts (Assembly Language & C)
Tech_MX
 
PPT
Motherboard of a pc
Tech_MX
 
PPTX
More on Lex
Tech_MX
 
PPTX
MultiMedia dbms
Tech_MX
 
PPTX
Merging files (Data Structure)
Tech_MX
 
PPTX
Memory dbms
Tech_MX
 
Virtual base class
Tech_MX
 
Uid
Tech_MX
 
Theory of estimation
Tech_MX
 
Templates in C++
Tech_MX
 
String & its application
Tech_MX
 
Statistical quality__control_2
Tech_MX
 
Stack data structure
Tech_MX
 
Stack Data Structure & It's Application
Tech_MX
 
Spss
Tech_MX
 
Spanning trees & applications
Tech_MX
 
Set data structure 2
Tech_MX
 
Set data structure
Tech_MX
 
Real time Operating System
Tech_MX
 
Parsing
Tech_MX
 
Mouse interrupts (Assembly Language & C)
Tech_MX
 
Motherboard of a pc
Tech_MX
 
More on Lex
Tech_MX
 
MultiMedia dbms
Tech_MX
 
Merging files (Data Structure)
Tech_MX
 
Memory dbms
Tech_MX
 
Ad

Recently uploaded (19)

PPTX
Line Up Activity For Kids and Adult.....
cynthiamarasigan
 
PPTX
一比一原版(Newman毕业证)纽曼大学毕业证如何办理
Taqyea
 
PDF
cyanean_Lab_Reportdfd dfdsfsdfsd f dsf.pdf
REYESTACZAEDGARALEJA
 
DOCX
The_Owl_and_the_Crow_Kalila_wa_Dimna.docx from fable
ranamutahir19
 
PPTX
原版德国德累斯顿国际大学毕业证(DIU毕业证书)如何办理
Taqyea
 
PDF
How Modern Filmmakers Plan, Shoot, and Deliver Blockbuster Movies.pdf
All Writers Destination
 
PDF
WKA #6: The Adventures - "FOUND FAMILY" TRANSCRIPT.pdf
Optimistic18
 
PPTX
一比一原版(UoD毕业证)邓迪大学毕业证如何办理
Taqyea
 
PDF
WKA #18: Mirror Memoria - "TATTOO" TRANSCRIPT.pdf
Optimistic18
 
PDF
Sanchit batra best magician in India For all Events.pdf
Sanchit Batra
 
PPTX
OTT Channel Migration_AABC Overview_Operations Briefing.pptx
SobnavalleKhishmu
 
PDF
Waddell Scavenger Hunt Presentation-2.pdf
peytonwaddell94
 
PPTX
Gradec 1 HeaYTRJTYJRTYJRJlth 4th grading.pptx
mangalindanjerremyjh
 
PDF
Peyton Waddell Scavenger Hunt Presentation.pdf
peytonwaddell94
 
PPTX
一比一原版(DCU毕业证书)都柏林城市大学毕业证如何办理
Taqyea
 
PPTX
ARENA BOLA 1&2 Contigency Plan - ASTRO Broadcast pptx
SobnavalleKhishmu
 
PPT
chapter 10.pptkkkkkkkkkkkkkkkkkkkkkkkkkk
trishalasharma7
 
PPTX
03 Pradeep Sane_Ethics & Prof Resp03 Pradeep Sane_Ethics & Prof 03 Pradeep Sa...
Kislaychaurasia
 
PPTX
Basic ppt templatecbnvjmbjbhknkl,vhv.pptx
Apurvanand Sahay
 
Line Up Activity For Kids and Adult.....
cynthiamarasigan
 
一比一原版(Newman毕业证)纽曼大学毕业证如何办理
Taqyea
 
cyanean_Lab_Reportdfd dfdsfsdfsd f dsf.pdf
REYESTACZAEDGARALEJA
 
The_Owl_and_the_Crow_Kalila_wa_Dimna.docx from fable
ranamutahir19
 
原版德国德累斯顿国际大学毕业证(DIU毕业证书)如何办理
Taqyea
 
How Modern Filmmakers Plan, Shoot, and Deliver Blockbuster Movies.pdf
All Writers Destination
 
WKA #6: The Adventures - "FOUND FAMILY" TRANSCRIPT.pdf
Optimistic18
 
一比一原版(UoD毕业证)邓迪大学毕业证如何办理
Taqyea
 
WKA #18: Mirror Memoria - "TATTOO" TRANSCRIPT.pdf
Optimistic18
 
Sanchit batra best magician in India For all Events.pdf
Sanchit Batra
 
OTT Channel Migration_AABC Overview_Operations Briefing.pptx
SobnavalleKhishmu
 
Waddell Scavenger Hunt Presentation-2.pdf
peytonwaddell94
 
Gradec 1 HeaYTRJTYJRTYJRJlth 4th grading.pptx
mangalindanjerremyjh
 
Peyton Waddell Scavenger Hunt Presentation.pdf
peytonwaddell94
 
一比一原版(DCU毕业证书)都柏林城市大学毕业证如何办理
Taqyea
 
ARENA BOLA 1&2 Contigency Plan - ASTRO Broadcast pptx
SobnavalleKhishmu
 
chapter 10.pptkkkkkkkkkkkkkkkkkkkkkkkkkk
trishalasharma7
 
03 Pradeep Sane_Ethics & Prof Resp03 Pradeep Sane_Ethics & Prof 03 Pradeep Sa...
Kislaychaurasia
 
Basic ppt templatecbnvjmbjbhknkl,vhv.pptx
Apurvanand Sahay
 

Ascii adjust & decimal adjust

  • 2. INSTRUCTIONS  AAA - ASCII Adjust After Addition  AAS - ASCII Adjust After Subtraction  AAM - ASCII Adjust After Multiply  AAD - ASCII Adjust Before Division  DAA - Decimal Adjust for Addition  DAS - Decimal Adjust for Subtraction 2
  • 3. INTRODUCTION The PC supports BCD format, Uses of BCD 1)No loss of precision 2)Simpler to perform arithmetic operation on small values from keyboard BCD can be stored in two way: Unpacked BCD Packed BCD 3
  • 4. Unpacked BCD Data Unpacked BCD representation contains only One decimal digit per byte. The digit is stored in the least significant 4 bits; the most significant 4 bits are not relevant to the value of the represented number. Example: Representing 1527 01 05 02 07h 4
  • 5. Packed BCD Data Packed BCD representation packs two Decimal digits into a single byte. Example: Representing 1527 15 27h 5
  • 6. ASCII Adjust After Addition Adjusts the result of the addition of two unpacked BCD values to create a unpacked BCD result. Operation 1: In AL If rightmost nibble is >9 (ie)A to F Or AuxilaryFlag=1 ADD 6 to rightmost nibble 6
  • 7. Operation 2: Clear left nibble form AL. Operation 3: In AH ADD 1 Operation 4: Set Carry and AuxilaryCarry 7
  • 8. .model small .data b1 dw 38h b2 dw 34h .code mov ax,@data mov ds,ax mov ax,b1 ;moving unpacked BCD into ax mov bx,b2 ;moving unpacked BCD into bx add ax,bx aaa ;adjusting unpacked BCD after addition or ax,3030h end 8
  • 9. ASCII Adjust After Subtraction Adjusts the result of the subtraction of two unpacked BCD values to create a unpacked BCD result. Operation 1: a)AAS checks the rightmost nibble in AL b)If rightmost nibble is >9 (ie)A to F Or AuxilaryFlag=1 c)Then Subtract 6 from rightmost nibble 9
  • 10. Operation 2: Clear left nibble in AL. Operation 3: Subtracts 1 from AH Operation 4: Set Carry and AuxilaryCarry 10
  • 11. Example : d1 contains 34h , d2 contains 38h of byte type Ax AF Mov AL, d1 ; 0034 Sub AL, d2; 00fc 1 AAS ; ff06 1  since the rightmost digit of AL is c , subtract 6 from AL  Subtract 1 from ah, set AF and CF flags  The answer is -4, is ff06 in 10’s complement 11
  • 12. .model small .data b1 dw 38h b2 dw 34h .code mov ax,@data mov ds,ax mov ax,b1 ;moving unpacked BCD into ax mov bx,b2 ;moving unpacked BCD into bx sub ax,bx aas ;adjusting unpacked BCD after subtraction or ax,3030h end 12
  • 13. ASCII Adjust After Multiplication  For multiplication and Division of ASCII numbers require that the numbers first be converted into unpacked BCD format.  Before Multiplication First clear the leftmost nibble in each Byte.  After Multiplication  AAM performs the following operations 1) Divides AL value by 10 (0AH) 2) Stores Quotient in AH 3) Store Remainder in AL 13
  • 14. Example: AL contains 35H and CL contains 39H Instruction comment AX CL and CL, 0Fh; Convert CL to 09 0035 39 and AL,0Fh; Convert AL to 05 0005 09 mul CL; Multiply AL by CL 002D AAM ; Convert to unpacked 0405 BCD Or AX,3030h; covert to ASCII 3435 14
  • 15. Mul operation generates 45 (002Dh) in AX  AAM divides this value by 10, so quotient of 04 in AH and remainder of 05 in AL  OR instruction converts the unpacked BCD to ASCII format 15
  • 16. .model small .data b1 dw 39h ; 9 in ASCII Format b2 dw 35h ; 5 in ASCII Format .code mov ax,@data mov ds,ax mov ax,b1 ;AX=0039h and AL,0fh ;AX=0009h mov bx,b2 ;BX=0035h and bl,0fh ;BX=0005h mul bx ;AX=002Dh aam or ax,3030h end 16
  • 17. ASCII Adjust Before Division  AAD allows for a 2-Byte Dividend in AX. The divisor can be only a single Byte(0-9)  Before Division First clear the leftmost nibble in each Byte.  Operations done by AAD instruction 1) AAD multiplies the AH by 10(0Ah). 2) Then adds the product to AL and clears the AH  After AAD , division is performed. 17
  • 18. Example: AX contains 3238 (28) - Dividend CL contains 37 (07) – Divisor Instruction comment AX CL and CL,0Fh; convert to unpacked 3238 07 BCD and AX,0F0Fh; convert to unpacked 0208 07 BCD AAD; convert to binary 001C div CL; divide by 7 0004 18
  • 19. AAD multiplies the AH by 10(0Ah)  Adds the product 20(14h) to the AL and clears the AH  The result is 001Ch, is hex representation of decimal 28  Then division is performed.  Remainder stored in AH, Quotient stored in AL 19
  • 20. model small .data b1 dw 3238h ; 28 in ASCII Format b2 db 37h ; 7 in ASCII Format .code mov ax,@data mov ds,ax mov ax,b1 ;AX=3238h and ax,0f0fh ;AX=0208h mov cl,b2 ;CL=37h and cl,0fh ;CL=07h aad ; AX= 001c div cl ; AX=0004 or ax,3030h; AX=3034 end 20
  • 21. Decimal Adjust To adjust the result of packed BCD numbers which stored in AL. DAA - Decimal Adjust for Addition DAS - Decimal Adjust for Subtraction 21
  • 22. Decimal Adjust for Addition DAA performs the following operations: Operation 1: If AL is >9 (ie) A to F or AuxilaryCarry=1 then ADD 6 to AL Set AuxilaryCarry=1 22
  • 23. Operation 2: If AL contains value > 99 or Carry=1 then ADD 60 to AL and set Carry =1 Otherwise AuxilaryCarry=0 ,carry=0 23
  • 24. AL contains 45h BL contains 45h Instruction Comment AL ADD AL,BL ; AL=AL+BL 8Ah DAA ; Adjust packed BCD 90h addition 24
  • 25. DAA checks the rightmost nibble of AL, it is A so add 6 to AL  Now AL = 90 25
  • 26. .model small .data d1 dw 45h ;moving 45 as packed BCD d2 dw 45h ;moving 45 as packed BCD .code mov ax,@data mov ds,ax mov ax,d1 mov bx,d2 add ax,bx daa ;adjusting the packed BCD after addition end 26
  • 27. Decimal Adjust for Subtraction Operations performed by DAS : If AL is >9 (ie) A to F or AuxilaryCarry=1 then Subtract 6 from AL Set Carry=1 Otherwise AuxilaryCarry=0 ,carry=0 27
  • 28. AL contains 80h BL contains 49h Instruction Comment AL SUB AL,BL ; AL=AL-BL 37h DAS ; Adjust packed BCD 31h Subtraction 28
  • 29. .model small .data d1 dw 57h d2 dw 48h .code mov ax,@data mov ds,ax mov ax,d1 ;moving 45 as packed BCD mov bx,d2 ;moving 45 as packed BCD sub ax,bx das ; adjusting the packed BCD after subraction end 29
  • 30. THANK U 30