2
Most read
3
Most read
9
Most read
DAA AND DAS
Microprocessor
Aat-2
DECIMAL ADJUST AFTER ADDITION
• The DAA (Decimal Adjust after Addition) instruction allows
addition of numbers represented in 8-bit packed BCD code. It is
used immediately after normal addition instruction operating on
BCD codes.
• This instruction assumes the AL register as the source and the
destination, and hence it requires no operand.
• The effect of DAS (Decimal Adjust after Subtraction) instruction is
similar to that of DAA, except that it is used after a subtraction
instruction.
MP
EXAMPLE
• Example: ADD AL, BL
• Before: AL=79H BL=35H EFLAGS(OSZAPC)=XXXXXX
• After: AL=AEH BL=35H EFLAGS(0SZAPC)=110000
MP
EXAMPLE
• Decimal adjust after addition
ADD AL,BL
AL=45H
BL=45H
ADD AL+BL=90H ADD 0100 0101
0100 0101
1 1 1
1000 1010 LSB>9 Add 6
so 1000 1010
0110
1001 0000=90H
MP
FLAGS AND REGISTER AFFECTED
• The CF and AF flags are set if the adjustment of the value results
in a decimal carry in either digit of the result (see the
“Operation” section above). The SF, ZF, and PF flags are set
according to the result. The OF flag is undefined.
MP
SAMPLE CODE
.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
MP
DECIMAL ADJUST AL AFTER SUBTRACTION
• Adjusts the result of the subtraction of two packed BCD values to
create a packed BCD result.
• The AL register is the implied source and destination operand.
• The DAS instruction is only useful when it follows a SUB instruction
that subtracts (binary subtraction) one 2-digit, packed BCD value
from another and stores a byte result in the AL register.
• The DAS instruction then adjusts the contents of the AL register to
contain the correct 2-digit, packed BCD result. If a decimal borrow
is detected, the CF and AF flags are set accordingly.
MP
EXAMPLE
• Example: SUB AL, BL
• Before:
AL=35H BL=47H EFLAGS(OSZAPC)=XXXXXX
After: AL=EEH BL=47H EFLAGS(0SZAPC)=010111
MP
Example: Decimal adjust after subtraction
SUB AL,BL
AL=86H
BL=57H
SUB AL-BL=29H SUB 1000 0110
0101 0111 2’s complement is 10101001
1000 0110
1010 1001
0010 1111 LSB>9 Add -6
(2) (F) so 0010 1111
1010
0010 1001
• (2) (9)
MP
FLAGS AND REGISTER AFFECTED
• The CF and AF flags are set if the adjustment of the value results
in a decimal borrow in either digit of the result (see the
"Operation" section above). The SF, ZF, and PF flags are set
according to the result. The OF flag is undefined.
MP
SAMPLE CODE
.model small
.data
d1 dw 86h
d2 dw 57h
.code
mov ax,@data
mov ds,ax
mov ax,d1 ;moving 86 as packed BCD
mov bx,d2 ;moving 57 as packed BCD
sub ax,bx
das ; adjusting the packed BCD after subraction
MP

More Related Content

PPT
8086 pin details
PPTX
Memory banking-of-8086-final
PPTX
Byte and string manipulation 8086
PDF
Difference b/w 8085 & 8086
PPTX
flag register of 8086
PPTX
Flag Registers (Assembly Language)
PPTX
Time delay programs and assembler directives 8086
PPT
Computer architecture pipelining
8086 pin details
Memory banking-of-8086-final
Byte and string manipulation 8086
Difference b/w 8085 & 8086
flag register of 8086
Flag Registers (Assembly Language)
Time delay programs and assembler directives 8086
Computer architecture pipelining

What's hot (20)

PPTX
priority interrupt computer organization
PPTX
Stack in 8085 microprocessor
PPT
Microprocessor 80386
PPT
8085 interrupts
PPTX
Bcd and ascii arithmetic instructions
PDF
Introduction to ibm pc assembly language
PDF
Instruction formats-in-8086
PPTX
Logical micro-operations
PPTX
Interrupts of 8086
PPTX
Pin diagram 8085
PPTX
Flags registers
PPTX
Timing Diagram.pptx
PPTX
Instruction sets of 8086
PPTX
8086 Microprocessor Pipeline Architecture.pptx
PDF
Input-Output Modules
PDF
8086 instructions
PPTX
8086 microprocessor-architecture
PPT
8086-instruction-set-ppt
PPTX
Minimum Modes and Maximum Modes of 8086 Microprocessor
PPT
Introduction to Interrupts of 8085 microprocessor
priority interrupt computer organization
Stack in 8085 microprocessor
Microprocessor 80386
8085 interrupts
Bcd and ascii arithmetic instructions
Introduction to ibm pc assembly language
Instruction formats-in-8086
Logical micro-operations
Interrupts of 8086
Pin diagram 8085
Flags registers
Timing Diagram.pptx
Instruction sets of 8086
8086 Microprocessor Pipeline Architecture.pptx
Input-Output Modules
8086 instructions
8086 microprocessor-architecture
8086-instruction-set-ppt
Minimum Modes and Maximum Modes of 8086 Microprocessor
Introduction to Interrupts of 8085 microprocessor
Ad

Similar to DAA AND DAS (20)

PPTX
Bcd arithmetic instructions
PPTX
Ascii arithmetic instructions
PPT
Instruction set of 8086
DOCX
Notes aaa aa
PDF
Instructionsetof8086 180224060745(3)
DOCX
Instruction set of 8086
PPTX
Ascii adjust & decimal adjust
PPTX
Instruction 4.pptx
PPTX
Microprocessor 8086 instruction description
DOCX
Notes all instructions
PPTX
Mastering Assembly Language: Programming with 8086
PDF
Unit 2 assembly language programming
PDF
Microprocessor 8086-lab-mannual
PPTX
Chapter 3 programming concepts-ii
DOC
Microprocessor lab
PDF
Instruction set-of-8086
DOCX
Notes arithmetic instructions
PPT
Addressing modes
PPTX
MPMC Architecture of 8085 Microprocessor and Programming.pptx
PPTX
Assembly language.pptx
Bcd arithmetic instructions
Ascii arithmetic instructions
Instruction set of 8086
Notes aaa aa
Instructionsetof8086 180224060745(3)
Instruction set of 8086
Ascii adjust & decimal adjust
Instruction 4.pptx
Microprocessor 8086 instruction description
Notes all instructions
Mastering Assembly Language: Programming with 8086
Unit 2 assembly language programming
Microprocessor 8086-lab-mannual
Chapter 3 programming concepts-ii
Microprocessor lab
Instruction set-of-8086
Notes arithmetic instructions
Addressing modes
MPMC Architecture of 8085 Microprocessor and Programming.pptx
Assembly language.pptx
Ad

Recently uploaded (20)

PDF
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
PDF
Visual Aids for Exploratory Data Analysis.pdf
PPTX
Feature types and data preprocessing steps
PDF
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
PPTX
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
PPTX
communication and presentation skills 01
PPTX
Management Information system : MIS-e-Business Systems.pptx
PPT
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PDF
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
PPTX
introduction to high performance computing
PDF
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
PDF
Categorization of Factors Affecting Classification Algorithms Selection
PDF
Design Guidelines and solutions for Plastics parts
PPTX
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
PPTX
Module 8- Technological and Communication Skills.pptx
PDF
August -2025_Top10 Read_Articles_ijait.pdf
PPTX
Fundamentals of safety and accident prevention -final (1).pptx
PPTX
CyberSecurity Mobile and Wireless Devices
PDF
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
PDF
distributed database system" (DDBS) is often used to refer to both the distri...
EXPLORING LEARNING ENGAGEMENT FACTORS INFLUENCING BEHAVIORAL, COGNITIVE, AND ...
Visual Aids for Exploratory Data Analysis.pdf
Feature types and data preprocessing steps
A SYSTEMATIC REVIEW OF APPLICATIONS IN FRAUD DETECTION
Graph Data Structures with Types, Traversals, Connectivity, and Real-Life App...
communication and presentation skills 01
Management Information system : MIS-e-Business Systems.pptx
INTRODUCTION -Data Warehousing and Mining-M.Tech- VTU.ppt
PREDICTION OF DIABETES FROM ELECTRONIC HEALTH RECORDS
introduction to high performance computing
Accra-Kumasi Expressway - Prefeasibility Report Volume 1 of 7.11.2018.pdf
Categorization of Factors Affecting Classification Algorithms Selection
Design Guidelines and solutions for Plastics parts
Sorting and Hashing in Data Structures with Algorithms, Techniques, Implement...
Module 8- Technological and Communication Skills.pptx
August -2025_Top10 Read_Articles_ijait.pdf
Fundamentals of safety and accident prevention -final (1).pptx
CyberSecurity Mobile and Wireless Devices
Artificial Superintelligence (ASI) Alliance Vision Paper.pdf
distributed database system" (DDBS) is often used to refer to both the distri...

DAA AND DAS

  • 2. DECIMAL ADJUST AFTER ADDITION • The DAA (Decimal Adjust after Addition) instruction allows addition of numbers represented in 8-bit packed BCD code. It is used immediately after normal addition instruction operating on BCD codes. • This instruction assumes the AL register as the source and the destination, and hence it requires no operand. • The effect of DAS (Decimal Adjust after Subtraction) instruction is similar to that of DAA, except that it is used after a subtraction instruction. MP
  • 3. EXAMPLE • Example: ADD AL, BL • Before: AL=79H BL=35H EFLAGS(OSZAPC)=XXXXXX • After: AL=AEH BL=35H EFLAGS(0SZAPC)=110000 MP
  • 4. EXAMPLE • Decimal adjust after addition ADD AL,BL AL=45H BL=45H ADD AL+BL=90H ADD 0100 0101 0100 0101 1 1 1 1000 1010 LSB>9 Add 6 so 1000 1010 0110 1001 0000=90H MP
  • 5. FLAGS AND REGISTER AFFECTED • The CF and AF flags are set if the adjustment of the value results in a decimal carry in either digit of the result (see the “Operation” section above). The SF, ZF, and PF flags are set according to the result. The OF flag is undefined. MP
  • 6. SAMPLE CODE .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 MP
  • 7. DECIMAL ADJUST AL AFTER SUBTRACTION • Adjusts the result of the subtraction of two packed BCD values to create a packed BCD result. • The AL register is the implied source and destination operand. • The DAS instruction is only useful when it follows a SUB instruction that subtracts (binary subtraction) one 2-digit, packed BCD value from another and stores a byte result in the AL register. • The DAS instruction then adjusts the contents of the AL register to contain the correct 2-digit, packed BCD result. If a decimal borrow is detected, the CF and AF flags are set accordingly. MP
  • 8. EXAMPLE • Example: SUB AL, BL • Before: AL=35H BL=47H EFLAGS(OSZAPC)=XXXXXX After: AL=EEH BL=47H EFLAGS(0SZAPC)=010111 MP
  • 9. Example: Decimal adjust after subtraction SUB AL,BL AL=86H BL=57H SUB AL-BL=29H SUB 1000 0110 0101 0111 2’s complement is 10101001 1000 0110 1010 1001 0010 1111 LSB>9 Add -6 (2) (F) so 0010 1111 1010 0010 1001 • (2) (9) MP
  • 10. FLAGS AND REGISTER AFFECTED • The CF and AF flags are set if the adjustment of the value results in a decimal borrow in either digit of the result (see the "Operation" section above). The SF, ZF, and PF flags are set according to the result. The OF flag is undefined. MP
  • 11. SAMPLE CODE .model small .data d1 dw 86h d2 dw 57h .code mov ax,@data mov ds,ax mov ax,d1 ;moving 86 as packed BCD mov bx,d2 ;moving 57 as packed BCD sub ax,bx das ; adjusting the packed BCD after subraction MP