Eee410_lecture11 - EEE 410 Microprocessors I Fall 04/05 Lecture Notes 11 Outline of the Lecture BCD Addition and correction ASCII addition and

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
EEE 410 – Microprocessors I Fall 04/05 – Lecture Notes # 11 Outline of the Lecture BCD Addition and correction ASCII addition and subtraction Rotate Instructions BCD A DDITION AND CORRECTION Ex1: MOV AL,17H Ex2: MOV AL,52H ADD AL,28H ADD AL,87H result=3FH result=D9H (not a BCD) (not a BCD) To solve these problems add 6 to the lower nibble of 3FH and upper nibble of D9H. 3F + 6 = 45H D9 + 60 = 139H Now the results are BCD. There is a special instruction to do this correction. DAA ;Decimal Adjust for Addition DAA will add 6 to the lower or upper nibble if needed. Ex: DATA1 DB 47H DATA2 DB 25H DATA3 DB ? MOV AL,DATA1 ;AL holds the first BCD operand MOV BL,DATA2 ;BL holds the second BCD ADD AL,BL ;BCD addition DAA ;adjust for BCD addition MOV DATA3,AL ;store result in correct BCD form DAA works only after the ADD and ADC instruction. (E.g. it doesn’t work with INC instruction) In addition the destination operand must be AL in order for DAA to work. Note that in BCD addition the operands can never have any digit greater than 9. Summary of DAA action 1. If after an ADD or ADC instruction the lower nibble (4 bits) is greater than 9, or if AF=1, add 0110 to the lower 4 bits. 2. If the upper nibble is greater than 9, or CF =1, add 0110 to the upper nibble. AF (Auxiliary carry Flag) is only used for BCD addition and correction.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 05/26/2011 for the course EEE 410 taught by Professor Hasandemirel during the Spring '10 term at Eastern Mediterranean University.

Page1 / 4

Eee410_lecture11 - EEE 410 Microprocessors I Fall 04/05 Lecture Notes 11 Outline of the Lecture BCD Addition and correction ASCII addition and

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online