SlideShare a Scribd company logo
1 of 12
Microprocessor & its Applications
Module 3 Continued……
Dr. Girisha G S
Dept. of CSE
SoE, DSU, Bengaluru
1
• BCD AND ASCII ARITHMETIC Instructions
- DAA, DAS, AAA, AAD, AAM, AAS
Agenda
BCD (Binary-Coded Decimal) code :
- Four-bit code that represents one of the ten decimal digits from 0 to 9.
can not use hex digits A-F
- Let us take an Example:
consider 10 as a decimal number
Its Binary Form will be 1010
Its BCD will be 0001 0000
- BCD can be stored in two way
- Unpacked BCD
- Packed BCD
Packed BCD
- Packed BCD data are stored as two digits per byte
E.g. 17d is stored as 17= 0001 0111
Unpacked BCD
- Unpacked BCD data are stored as one digit per byte
E.g. 17d is stored as 01 07 = 0000 0001 0000 0111
ASCII Code (American Standard Code for Information Interchange)
- ASCII code is a 7 bit code which assigns a binary value to letters, numbers &
other characters from 0 to 127 in decimal (00-7F in hexadecimal)
- In this code number 0 through 9 are represented as 30 through 39
- letters A through Z are represented as 41H through 5AH
- letters a through z are represented as 61H through 7AH
Example: 1234 is stored as 31 32 33 34H
ASCII for 1 is 31H, for 2 is 32H etc.
BCD Arithmetic
- 8086 Microprocessor allows arithmetic manipulation of BCD data
- This is accomplished by instructions that adjust the numbers for BCD
arithmetic
- used to correct the BCD addition/subtraction
- These instructions do not take any operands. The operand is assumed to
be in AL.
• DAA (decimal adjust after addition) instruction follows BCD addition.
• DAS (decimal adjust after subtraction) instruction follows BCD subtraction
DAA: Decimal adjust after addition
Syntax: DAA ; AL←AL converted for BCD addition
- This instruction is used to convert the result of addition of two packed BCD numbers to a valid
BCD number.
- The instruction should be issued after an ADD, ADC instruction. The result has to be only in AL
register.
- On execution of this instruction,
- If the lower nibble in AL register is greater than 9 or AF is set, then 6 will be added to the
AL register. & the AF is set.
- If the upper nibble in AL register is greater than 9 or CF is set, then 60 will be added to the
AL register. & the CF is set.
Flags affected: AF, CF, PF, ZF
Examples:
MOV AL,53H ; AL<-53 BCD = 01010011
MOV CL, 29H; CL<-29 BCD= 00101001
ADD AL, CL ; AL<-7CH = 01111100
DAA ; add 6 to AL because C>9
; AL←7C = 01111100
+6 = 00000110
; AL←82 (BCD)= 10000010
DAS: Decimal adjust after subtraction
- This instruction is used to convert the result of subtraction of two packed BCD numbers
to a valid BCD number.
- The instruction should be issued after an SUB, SBB instruction. The result has to be
only in AL register.
- On execution of this instruction,
- if the lower nibble in AL register is greater than 9 or AF is set, then 6 will be
subtracted from the AL register. & the AF is set.
- If the result of the upper nibble in AL register is greater than 9 or CF is set, then 60
will be subtracted from the AL register. & the CF is set.
Examples:
MOV AL,32H ; Load 32 BCD = 00110010
MOV CL, 17H; Load 17 BCD = 00010111
SUB AL, CL ; AL←32H-17H = 00011010
; AL←1BH
DAS ; subtract 6 from AL because B>9
; AL←1B-6 = 00011010
; - 00000110
; AL←15 (BCD) = 00010101
ASCII Arithmetic
- The ASCII arithmetic instructions function with ASCII-coded numbers.
- These numbers range in value from 30H to 39H for the numbers 0-9.
- There are four instructions used with ASCII arithmetic operations:
• AAA (ASCII adjust after addition)
• AAD (ASCII adjust before division)
• AAM (ASCII adjust after multiplication)
• AAS (ASCII adjust after subtraction)
AAA - ASCII adjust after addition
- The AAA instruction can be used after addition to get the correct result in unpacked BCD
form.
- The AAA instruction works only on AL register. The AAA instruction converts the
resulting content of AL to unpacked BCD form.
- On execution,
- this instruction clears the upper nibble of AL, AH register should be cleared before
adding.
- If lower nibble of AL>9 or AF=1, then it add 6 to the AL register, add 1 to AH register &
set AF & CF = 1.
- In all other cases, the upper nibble of AL is cleared.
- This instruction does not give exact ASCII codes of the SUM, but they can be obtained
by adding 3030H to AX.
E.g. ADD AL,CL ; Before : AL=34H, ASCII 4
; CL=38H, ASCII 8
; After: AL=6CH
AAA ; AL = C + 6
; AL = 12
; AH=01
; AL=02
AAS: ASCII adjust after subtraction
- The AAS instruction can be used after subtraction to get the correct result in
unpacked BCD form.
- The AAS instruction works only on AL register. The AAS instruction converts
the resulting content of AL to unpacked BCD form.
- The adjustment is needed only if the result is negative.
Example: SUB AL, CL ; Before : AL=38H, ASCII 8; CL=32H, ASCII 2
; After: AL=06
AAS ; AL=06 (BCD )
; AX=0006
AAD: ASCII adjust before division
- The instruction AAD can be used to convert the two unpacked BCD digit in AH & AL register
to the equivalent binary number in the register AL. i.e. AAD instruction adjusts the number
in AX before dividing two unpacked decimal numbers.
- This instruction should be issued before the division (DIV) instruction.
- The division instruction will place the quotient in AL register & remainder in the AH
register. The upper nibble of the AH & AL are filled with zero.
- It works as follows: Multiply AH by 10 (0AH) & add it to AL & set AH to 0
Example: AAD ; Before: AH= 02H , AL=07H, CL=07H
; After: AX=001BH
DIV CL
AAM: ASCII adjust after multiplication
- The instruction AAM can be used to convert the result of multiplication of two
valid unpacked BCD number in AX.
- This instruction should be issued after multiplication instruction.
- It works as follows: AL is divided by 10, quotient is stored in AH & remainder in
AL
Example: MUL CL ; Before : AL=04H, CL=06H
; After : AX=0018H (24D)
AAM ; AX=02 04 (unpacked BCD form)

More Related Content

What's hot

fixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.pptfixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.pptRavikumarR77
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computerswarda aziz
 
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086COMSATS Abbottabad
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionBadrul Alam
 
Bcd arithmetic instructions
Bcd arithmetic instructionsBcd arithmetic instructions
Bcd arithmetic instructionsDr. Girish GS
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly languagewarda aziz
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of CompilerPreethi AKNR
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086COMSATS Abbottabad
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Abhimanyu Mishra
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)mihir jain
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly LanguageMotaz Saad
 
Chapt 01 Assembly Language
Chapt 01 Assembly LanguageChapt 01 Assembly Language
Chapt 01 Assembly LanguageHamza Akram
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organizationTushar B Kute
 

What's hot (20)

Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
fixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.pptfixed-point-vs-floating-point.ppt
fixed-point-vs-floating-point.ppt
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Organization of the ibm personal computers
Organization of the ibm personal computersOrganization of the ibm personal computers
Organization of the ibm personal computers
 
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
 
Lecture1 introduction compilers
Lecture1 introduction compilersLecture1 introduction compilers
Lecture1 introduction compilers
 
Logic Micro Operation
Logic Micro OperationLogic Micro Operation
Logic Micro Operation
 
Logical, Shift, and Rotate Instruction
Logical, Shift, and Rotate InstructionLogical, Shift, and Rotate Instruction
Logical, Shift, and Rotate Instruction
 
Bcd arithmetic instructions
Bcd arithmetic instructionsBcd arithmetic instructions
Bcd arithmetic instructions
 
Introduction to ibm pc assembly language
Introduction to ibm pc assembly languageIntroduction to ibm pc assembly language
Introduction to ibm pc assembly language
 
Techniques & applications of Compiler
Techniques & applications of CompilerTechniques & applications of Compiler
Techniques & applications of Compiler
 
Chapter 1
Chapter 1Chapter 1
Chapter 1
 
Binary codes
Binary codesBinary codes
Binary codes
 
Binary Arithmetic Operations
Binary Arithmetic OperationsBinary Arithmetic Operations
Binary Arithmetic Operations
 
implementation of data instrucions in emu8086
implementation of data instrucions in emu8086implementation of data instrucions in emu8086
implementation of data instrucions in emu8086
 
Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1Theory of Automata and formal languages unit 1
Theory of Automata and formal languages unit 1
 
KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)KARNAUGH MAP(K-MAP)
KARNAUGH MAP(K-MAP)
 
Introduction to Assembly Language
Introduction to Assembly LanguageIntroduction to Assembly Language
Introduction to Assembly Language
 
Chapt 01 Assembly Language
Chapt 01 Assembly LanguageChapt 01 Assembly Language
Chapt 01 Assembly Language
 
Computer architecture and organization
Computer architecture and organizationComputer architecture and organization
Computer architecture and organization
 

Similar to Ascii arithmetic instructions

Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionDheeraj Suri
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjustTech_MX
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptxHebaEng
 
microcomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionmicrocomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionramya marichamy
 
8086 instructions
8086 instructions8086 instructions
8086 instructionsRavi Anand
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086Vijay Kumar
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)AmitPaliwal20
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086sravanithonta79
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3RLJIT
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2RLJIT
 

Similar to Ascii arithmetic instructions (20)

Al2ed chapter11
Al2ed chapter11Al2ed chapter11
Al2ed chapter11
 
Microprocessor 8086 instruction description
Microprocessor 8086 instruction descriptionMicroprocessor 8086 instruction description
Microprocessor 8086 instruction description
 
Module 2 (1).pptx
Module 2 (1).pptxModule 2 (1).pptx
Module 2 (1).pptx
 
Mod-2.pptx
Mod-2.pptxMod-2.pptx
Mod-2.pptx
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
 
DAA AND DAS
DAA AND DASDAA AND DAS
DAA AND DAS
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Arithmetic instrctions
Arithmetic instrctionsArithmetic instrctions
Arithmetic instrctions
 
Chap3 8086 artithmetic
Chap3 8086 artithmeticChap3 8086 artithmetic
Chap3 8086 artithmetic
 
8086 ins2 math
8086 ins2 math8086 ins2 math
8086 ins2 math
 
Chapter 3 8086 ins2 math
Chapter 3 8086 ins2 mathChapter 3 8086 ins2 math
Chapter 3 8086 ins2 math
 
Instruction 4.pptx
Instruction 4.pptxInstruction 4.pptx
Instruction 4.pptx
 
microcomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instructionmicrocomputer architecture - Arithmetic instruction
microcomputer architecture - Arithmetic instruction
 
8086 instructions
8086 instructions8086 instructions
8086 instructions
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)Instructionsetof8086 180224060745(3)
Instructionsetof8086 180224060745(3)
 
Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086Mastering Assembly Language: Programming with 8086
Mastering Assembly Language: Programming with 8086
 
15CS44 MP &MC Module 3
15CS44 MP &MC Module 315CS44 MP &MC Module 3
15CS44 MP &MC Module 3
 
15CS44 MP & MC Module 2
15CS44 MP & MC Module  215CS44 MP & MC Module  2
15CS44 MP & MC Module 2
 
Class4
Class4Class4
Class4
 

More from Dr. Girish GS

unix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grepunix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grepDr. Girish GS
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in backgroundDr. Girish GS
 
Customizing the unix environment
Customizing the unix environmentCustomizing the unix environment
Customizing the unix environmentDr. Girish GS
 
File systems and inodes
File systems and inodesFile systems and inodes
File systems and inodesDr. Girish GS
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expressionBasic regular expression, extended regular expression
Basic regular expression, extended regular expressionDr. Girish GS
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamDr. Girish GS
 
Logic instructions part 1
Logic instructions part 1Logic instructions part 1
Logic instructions part 1Dr. Girish GS
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsDr. Girish GS
 
Program control instructions
Program control instructionsProgram control instructions
Program control instructionsDr. Girish GS
 

More from Dr. Girish GS (13)

Unix- the process
Unix-  the processUnix-  the process
Unix- the process
 
unix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grepunix- Sort, uniq,tr,grep
unix- Sort, uniq,tr,grep
 
unix- the process states, zombies, running jobs in background
unix-  the process states, zombies, running jobs in backgroundunix-  the process states, zombies, running jobs in background
unix- the process states, zombies, running jobs in background
 
Unix - Filters
Unix - FiltersUnix - Filters
Unix - Filters
 
Customizing the unix environment
Customizing the unix environmentCustomizing the unix environment
Customizing the unix environment
 
File systems and inodes
File systems and inodesFile systems and inodes
File systems and inodes
 
Basic regular expression, extended regular expression
Basic regular expression, extended regular expressionBasic regular expression, extended regular expression
Basic regular expression, extended regular expression
 
Loop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progamLoop instruction, controlling the flow of progam
Loop instruction, controlling the flow of progam
 
Logic instructions part 1
Logic instructions part 1Logic instructions part 1
Logic instructions part 1
 
Bcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructionsBcd and ascii arithmetic instructions
Bcd and ascii arithmetic instructions
 
Rotate instructions
Rotate instructionsRotate instructions
Rotate instructions
 
Program control instructions
Program control instructionsProgram control instructions
Program control instructions
 
Memory interface
Memory interfaceMemory interface
Memory interface
 

Recently uploaded

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSSIVASHANKAR N
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSISrknatarajan
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...ranjana rawat
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )Tsuyoshi Horigome
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxupamatechverse
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...RajaP95
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130Suhani Kapoor
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduitsrknatarajan
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Serviceranjana rawat
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLSMANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
MANUFACTURING PROCESS-II UNIT-5 NC MACHINE TOOLS
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
UNIT-III FMM. DIMENSIONAL ANALYSIS
UNIT-III FMM.        DIMENSIONAL ANALYSISUNIT-III FMM.        DIMENSIONAL ANALYSIS
UNIT-III FMM. DIMENSIONAL ANALYSIS
 
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
(SHREYA) Chakan Call Girls Just Call 7001035870 [ Cash on Delivery ] Pune Esc...
 
Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(PRIYA) Rajgurunagar Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )SPICE PARK APR2024 ( 6,793 SPICE Models )
SPICE PARK APR2024 ( 6,793 SPICE Models )
 
Introduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptxIntroduction and different types of Ethernet.pptx
Introduction and different types of Ethernet.pptx
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
IMPLICATIONS OF THE ABOVE HOLISTIC UNDERSTANDING OF HARMONY ON PROFESSIONAL E...
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
VIP Call Girls Service Kondapur Hyderabad Call +91-8250192130
 
UNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular ConduitsUNIT-II FMM-Flow Through Circular Conduits
UNIT-II FMM-Flow Through Circular Conduits
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
(RIA) Call Girls Bhosari ( 7001035870 ) HI-Fi Pune Escorts Service
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...Top Rated  Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
 

Ascii arithmetic instructions

  • 1. Microprocessor & its Applications Module 3 Continued…… Dr. Girisha G S Dept. of CSE SoE, DSU, Bengaluru 1
  • 2. • BCD AND ASCII ARITHMETIC Instructions - DAA, DAS, AAA, AAD, AAM, AAS Agenda
  • 3. BCD (Binary-Coded Decimal) code : - Four-bit code that represents one of the ten decimal digits from 0 to 9. can not use hex digits A-F - Let us take an Example: consider 10 as a decimal number Its Binary Form will be 1010 Its BCD will be 0001 0000 - BCD can be stored in two way - Unpacked BCD - Packed BCD Packed BCD - Packed BCD data are stored as two digits per byte E.g. 17d is stored as 17= 0001 0111 Unpacked BCD - Unpacked BCD data are stored as one digit per byte E.g. 17d is stored as 01 07 = 0000 0001 0000 0111
  • 4. ASCII Code (American Standard Code for Information Interchange) - ASCII code is a 7 bit code which assigns a binary value to letters, numbers & other characters from 0 to 127 in decimal (00-7F in hexadecimal) - In this code number 0 through 9 are represented as 30 through 39 - letters A through Z are represented as 41H through 5AH - letters a through z are represented as 61H through 7AH Example: 1234 is stored as 31 32 33 34H ASCII for 1 is 31H, for 2 is 32H etc.
  • 5. BCD Arithmetic - 8086 Microprocessor allows arithmetic manipulation of BCD data - This is accomplished by instructions that adjust the numbers for BCD arithmetic - used to correct the BCD addition/subtraction - These instructions do not take any operands. The operand is assumed to be in AL. • DAA (decimal adjust after addition) instruction follows BCD addition. • DAS (decimal adjust after subtraction) instruction follows BCD subtraction
  • 6. DAA: Decimal adjust after addition Syntax: DAA ; AL←AL converted for BCD addition - This instruction is used to convert the result of addition of two packed BCD numbers to a valid BCD number. - The instruction should be issued after an ADD, ADC instruction. The result has to be only in AL register. - On execution of this instruction, - If the lower nibble in AL register is greater than 9 or AF is set, then 6 will be added to the AL register. & the AF is set. - If the upper nibble in AL register is greater than 9 or CF is set, then 60 will be added to the AL register. & the CF is set. Flags affected: AF, CF, PF, ZF Examples: MOV AL,53H ; AL<-53 BCD = 01010011 MOV CL, 29H; CL<-29 BCD= 00101001 ADD AL, CL ; AL<-7CH = 01111100 DAA ; add 6 to AL because C>9 ; AL←7C = 01111100 +6 = 00000110 ; AL←82 (BCD)= 10000010
  • 7. DAS: Decimal adjust after subtraction - This instruction is used to convert the result of subtraction of two packed BCD numbers to a valid BCD number. - The instruction should be issued after an SUB, SBB instruction. The result has to be only in AL register. - On execution of this instruction, - if the lower nibble in AL register is greater than 9 or AF is set, then 6 will be subtracted from the AL register. & the AF is set. - If the result of the upper nibble in AL register is greater than 9 or CF is set, then 60 will be subtracted from the AL register. & the CF is set. Examples: MOV AL,32H ; Load 32 BCD = 00110010 MOV CL, 17H; Load 17 BCD = 00010111 SUB AL, CL ; AL←32H-17H = 00011010 ; AL←1BH DAS ; subtract 6 from AL because B>9 ; AL←1B-6 = 00011010 ; - 00000110 ; AL←15 (BCD) = 00010101
  • 8. ASCII Arithmetic - The ASCII arithmetic instructions function with ASCII-coded numbers. - These numbers range in value from 30H to 39H for the numbers 0-9. - There are four instructions used with ASCII arithmetic operations: • AAA (ASCII adjust after addition) • AAD (ASCII adjust before division) • AAM (ASCII adjust after multiplication) • AAS (ASCII adjust after subtraction)
  • 9. AAA - ASCII adjust after addition - The AAA instruction can be used after addition to get the correct result in unpacked BCD form. - The AAA instruction works only on AL register. The AAA instruction converts the resulting content of AL to unpacked BCD form. - On execution, - this instruction clears the upper nibble of AL, AH register should be cleared before adding. - If lower nibble of AL>9 or AF=1, then it add 6 to the AL register, add 1 to AH register & set AF & CF = 1. - In all other cases, the upper nibble of AL is cleared. - This instruction does not give exact ASCII codes of the SUM, but they can be obtained by adding 3030H to AX. E.g. ADD AL,CL ; Before : AL=34H, ASCII 4 ; CL=38H, ASCII 8 ; After: AL=6CH AAA ; AL = C + 6 ; AL = 12 ; AH=01 ; AL=02
  • 10. AAS: ASCII adjust after subtraction - The AAS instruction can be used after subtraction to get the correct result in unpacked BCD form. - The AAS instruction works only on AL register. The AAS instruction converts the resulting content of AL to unpacked BCD form. - The adjustment is needed only if the result is negative. Example: SUB AL, CL ; Before : AL=38H, ASCII 8; CL=32H, ASCII 2 ; After: AL=06 AAS ; AL=06 (BCD ) ; AX=0006
  • 11. AAD: ASCII adjust before division - The instruction AAD can be used to convert the two unpacked BCD digit in AH & AL register to the equivalent binary number in the register AL. i.e. AAD instruction adjusts the number in AX before dividing two unpacked decimal numbers. - This instruction should be issued before the division (DIV) instruction. - The division instruction will place the quotient in AL register & remainder in the AH register. The upper nibble of the AH & AL are filled with zero. - It works as follows: Multiply AH by 10 (0AH) & add it to AL & set AH to 0 Example: AAD ; Before: AH= 02H , AL=07H, CL=07H ; After: AX=001BH DIV CL
  • 12. AAM: ASCII adjust after multiplication - The instruction AAM can be used to convert the result of multiplication of two valid unpacked BCD number in AX. - This instruction should be issued after multiplication instruction. - It works as follows: AL is divided by 10, quotient is stored in AH & remainder in AL Example: MUL CL ; Before : AL=04H, CL=06H ; After : AX=0018H (24D) AAM ; AX=02 04 (unpacked BCD form)

Editor's Notes

  1. Decimal numbers can be represented in one of the two forms: BCD and ASCII In BCD, each of the digit of the decimal number is represented by its binary form in 4 bits. In this code each decimal digit is represented by a 4-bit binary number. BCD is a way to express each of the decimal digits with a binary code. But in BCD code only first ten of these are used (0000 to 1001).The remaining six code combinations i.e. 1010 to 1111 are invalid in BCD. BCD information is stored in either packed or unpacked form(lower 4 bits represent number others are 0 In unpacked BCD a byte is used to contain a number. i.e contains only one digit per byte In packed BCD a byte has two BCD numbers i.e packs two decimal digits in a byte
  2. This is a standard set of characters understood by all computers, Each character is assigned a unique 7-bit code. they are mainly used for representing characters, such as characters "a" to "z" and number "0" to "9"
  3. To perform mathematical operations on BCD and ASCII. Operate with BCD data, used to correct the BCD addition/subtraction
  4. Used after add or adc to adjust the result back in to packed bcd format. Daa instruction adjust the result to bcd DAA performs the following operations. The daa instruction works as follows:
  5. Used after sub or sbb to adjust the result back in to packed bcd format.
  6. Converts the product available in AL in to unpacked BCD