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

8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
prasadpawaskar
 
INTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSORINTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSOR
Gurudev joshi
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
Revathi Subramaniam
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
hepzijustin
 
Shift micro operations & 4 bit combinational circuit shifter
Shift micro operations &  4 bit combinational circuit shifterShift micro operations &  4 bit combinational circuit shifter
Shift micro operations & 4 bit combinational circuit shifter
Monika Chauhan
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
warda aziz
 
Computer instructions
Computer instructionsComputer instructions
Computer instructionsAnuj Modi
 
Weighted and Non Weighted Codes
Weighted and Non Weighted CodesWeighted and Non Weighted Codes
Weighted and Non Weighted Codes
SubhamSatpathy2
 
80486 microprocessor
80486 microprocessor80486 microprocessor
80486 microprocessor
Mihika Shah
 
Addressing Modes Of 8086
Addressing Modes Of 8086Addressing Modes Of 8086
Addressing Modes Of 8086
Ikhlas Rahman
 
Booths Multiplication Algorithm
Booths Multiplication AlgorithmBooths Multiplication Algorithm
Booths Multiplication Algorithm
knightnick
 
Binary multipliers
Binary multipliersBinary multipliers
Binary multipliers
Syed Saeed
 
8086
80868086
8086 in minimum mode
8086 in minimum mode8086 in minimum mode
8086 in minimum mode
Sridari Iyer
 
Stack organization
Stack organizationStack organization
Stack organization
chauhankapil
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086
techbed
 
8086 Microprocessor powerpoint
8086  Microprocessor  powerpoint8086  Microprocessor  powerpoint
8086 Microprocessor powerpoint
Randhir Kumar
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
Dr. AISHWARYA N
 

What's hot (20)

8086 microprocessor-architecture
8086 microprocessor-architecture8086 microprocessor-architecture
8086 microprocessor-architecture
 
INTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSORINTERRUPTS OF 8086 MICROPROCESSOR
INTERRUPTS OF 8086 MICROPROCESSOR
 
Error detection & correction codes
Error detection & correction codesError detection & correction codes
Error detection & correction codes
 
Stack in 8085 microprocessor
Stack in 8085 microprocessorStack in 8085 microprocessor
Stack in 8085 microprocessor
 
Shift micro operations & 4 bit combinational circuit shifter
Shift micro operations &  4 bit combinational circuit shifterShift micro operations &  4 bit combinational circuit shifter
Shift micro operations & 4 bit combinational circuit shifter
 
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...
 
Computer instructions
Computer instructionsComputer instructions
Computer instructions
 
Weighted and Non Weighted Codes
Weighted and Non Weighted CodesWeighted and Non Weighted Codes
Weighted and Non Weighted Codes
 
80486 microprocessor
80486 microprocessor80486 microprocessor
80486 microprocessor
 
Addressing Modes Of 8086
Addressing Modes Of 8086Addressing Modes Of 8086
Addressing Modes Of 8086
 
Booths Multiplication Algorithm
Booths Multiplication AlgorithmBooths Multiplication Algorithm
Booths Multiplication Algorithm
 
Binary multipliers
Binary multipliersBinary multipliers
Binary multipliers
 
8086
80868086
8086
 
8086 in minimum mode
8086 in minimum mode8086 in minimum mode
8086 in minimum mode
 
Stack organization
Stack organizationStack organization
Stack organization
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 
1327 Addressing Modes Of 8086
1327 Addressing Modes Of 80861327 Addressing Modes Of 8086
1327 Addressing Modes Of 8086
 
8051 ch9
8051 ch98051 ch9
8051 ch9
 
8086 Microprocessor powerpoint
8086  Microprocessor  powerpoint8086  Microprocessor  powerpoint
8086 Microprocessor powerpoint
 
Addressing modes of 8086
Addressing modes of 8086Addressing modes of 8086
Addressing modes of 8086
 

Similar to Ascii adjust & decimal adjust

Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
Dr. Thippeswamy S.
 
Bcd arithmetic instructions
Bcd arithmetic instructionsBcd arithmetic instructions
Bcd arithmetic instructions
Dr. Girish GS
 
Ascii arithmetic instructions
Ascii arithmetic instructionsAscii arithmetic instructions
Ascii arithmetic instructions
Dr. Girish GS
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
Dr. Girish GS
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
Dr. Thippeswamy S.
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
Tirumalesh Nizampatnam
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
HebaEng
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
HarshitParkar6677
 
microcomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionmicrocomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instruction
ramya marichamy
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
HarshitParkar6677
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
HarshitParkar6677
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
HarshitParkar6677
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
RLJIT
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Jay Patel
 
8086 instruction set
8086  instruction set8086  instruction set
8086 instruction set
mengistu ketema
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
RLJIT
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
AmitPaliwal20
 
11-PLDs.pdf
11-PLDs.pdf11-PLDs.pdf
11-PLDs.pdf
KoayFT
 

Similar to Ascii adjust & decimal adjust (20)

Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
 
Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
 
Bcd arithmetic instructions
Bcd arithmetic instructionsBcd arithmetic instructions
Bcd arithmetic instructions
 
Ascii arithmetic instructions
Ascii arithmetic instructionsAscii arithmetic instructions
Ascii arithmetic instructions
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
microcomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionmicrocomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instruction
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
 
Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051Arithmetic & logical operations in 8051
Arithmetic & logical operations in 8051
 
arithmetic ins in 8051
arithmetic ins in 8051arithmetic ins in 8051
arithmetic ins in 8051
 
8086 instruction set
8086  instruction set8086  instruction set
8086 instruction set
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
 
11-PLDs.pdf
11-PLDs.pdf11-PLDs.pdf
11-PLDs.pdf
 

More from Tech_MX

Virtual base class
Virtual base classVirtual base class
Virtual base classTech_MX
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimationTech_MX
 
Templates in C++
Templates in C++Templates in C++
Templates in C++Tech_MX
 
String & its application
String & its applicationString & its application
String & its applicationTech_MX
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2Tech_MX
 
Stack data structure
Stack data structureStack data structure
Stack data structureTech_MX
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application Tech_MX
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applicationsTech_MX
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2Tech_MX
 
Set data structure
Set data structure Set data structure
Set data structure Tech_MX
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating SystemTech_MX
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Tech_MX
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pcTech_MX
 
More on Lex
More on LexMore on Lex
More on LexTech_MX
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbmsTech_MX
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)Tech_MX
 
Memory dbms
Memory dbmsMemory dbms
Memory dbmsTech_MX
 

More from Tech_MX (20)

Virtual base class
Virtual base classVirtual base class
Virtual base class
 
Uid
UidUid
Uid
 
Theory of estimation
Theory of estimationTheory of estimation
Theory of estimation
 
Templates in C++
Templates in C++Templates in C++
Templates in C++
 
String & its application
String & its applicationString & its application
String & its application
 
Statistical quality__control_2
Statistical  quality__control_2Statistical  quality__control_2
Statistical quality__control_2
 
Stack data structure
Stack data structureStack data structure
Stack data structure
 
Stack Data Structure & It's Application
Stack Data Structure & It's Application Stack Data Structure & It's Application
Stack Data Structure & It's Application
 
Spss
SpssSpss
Spss
 
Spanning trees & applications
Spanning trees & applicationsSpanning trees & applications
Spanning trees & applications
 
Set data structure 2
Set data structure 2Set data structure 2
Set data structure 2
 
Set data structure
Set data structure Set data structure
Set data structure
 
Real time Operating System
Real time Operating SystemReal time Operating System
Real time Operating System
 
Parsing
ParsingParsing
Parsing
 
Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)Mouse interrupts (Assembly Language & C)
Mouse interrupts (Assembly Language & C)
 
Motherboard of a pc
Motherboard of a pcMotherboard of a pc
Motherboard of a pc
 
More on Lex
More on LexMore on Lex
More on Lex
 
MultiMedia dbms
MultiMedia dbmsMultiMedia dbms
MultiMedia dbms
 
Merging files (Data Structure)
Merging files (Data Structure)Merging files (Data Structure)
Merging files (Data Structure)
 
Memory dbms
Memory dbmsMemory dbms
Memory dbms
 

Recently uploaded

Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and LoveMeet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
get joys
 
Hollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest galleryHollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest gallery
Zsolt Nemeth
 
I Know Dino Trivia: Part 3. Test your dino knowledge
I Know Dino Trivia: Part 3. Test your dino knowledgeI Know Dino Trivia: Part 3. Test your dino knowledge
I Know Dino Trivia: Part 3. Test your dino knowledge
Sabrina Ricci
 
Scandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.zaScandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.za
Isaac More
 
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
9u08k0x
 
240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf
Madhura TBRC
 
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
9u08k0x
 
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdfMatt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Azura Everhart
 
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and SafetyModern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
AITIX LLC
 
A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024
Indira Srivatsa
 
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to StardomYoung Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
greendigital
 
Christina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptxChristina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptx
madeline604788
 
The Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy DirectorThe Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy Director
Mark Murphy Director
 
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles onlineTreasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
Hidden Treasure Hunts
 
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docxThe Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
Xtreame HDTV
 
This Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I MadeThis Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I Made
Aarush Ghate
 
Reimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a SuccessReimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a Success
Mark Murphy Director
 
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog EternalMeet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
Blog Eternal
 
The Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy DirectorThe Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy Director
Mark Murphy Director
 
Skeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on ForumSkeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on Forum
Isaac More
 

Recently uploaded (20)

Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and LoveMeet Dinah Mattingly – Larry Bird’s Partner in Life and Love
Meet Dinah Mattingly – Larry Bird’s Partner in Life and Love
 
Hollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest galleryHollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest gallery
 
I Know Dino Trivia: Part 3. Test your dino knowledge
I Know Dino Trivia: Part 3. Test your dino knowledgeI Know Dino Trivia: Part 3. Test your dino knowledge
I Know Dino Trivia: Part 3. Test your dino knowledge
 
Scandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.zaScandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.za
 
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
哪里买(osu毕业证书)美国俄勒冈州立大学毕业证双学位证书原版一模一样
 
240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf240529_Teleprotection Global Market Report 2024.pdf
240529_Teleprotection Global Market Report 2024.pdf
 
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
高仿(nyu毕业证书)美国纽约大学毕业证文凭毕业证原版一模一样
 
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdfMatt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
Matt Rife Cancels Shows Due to Health Concerns, Reschedules Tour Dates.pdf
 
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and SafetyModern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
Modern Radio Frequency Access Control Systems: The Key to Efficiency and Safety
 
A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024
 
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to StardomYoung Tom Selleck: A Journey Through His Early Years and Rise to Stardom
Young Tom Selleck: A Journey Through His Early Years and Rise to Stardom
 
Christina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptxChristina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptx
 
The Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy DirectorThe Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy Director
 
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles onlineTreasure Hunt Puzzles, Treasure Hunt Puzzles online
Treasure Hunt Puzzles, Treasure Hunt Puzzles online
 
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docxThe Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
The Ultimate Guide to Setting Up Eternal IPTV on Your Devices.docx
 
This Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I MadeThis Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I Made
 
Reimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a SuccessReimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a Success
 
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog EternalMeet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
 
The Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy DirectorThe Journey of an Indie Film - Mark Murphy Director
The Journey of an Indie Film - Mark Murphy Director
 
Skeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on ForumSkeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on Forum
 

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