programb54 - Microprocessors& Applications(UPTU Appendix...

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

View Full Document Right Arrow Icon

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

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Microprocessors & Applications (UPTU) Appendix B Explanation : • Consider that a byte of data is present in the AL register and a second byte of data is present in the BL register. We have to subtract byte in AL with the byte in BL. Using sub instruction, add the contents of 2 registers. • Result will be stored in the AX register. • Use AAS instruction that will check if BCD is valid, if it is not valid then 6 is added to give proper BCD result. Assume AL = 0 0 1 1 1 0 0 1 ASCII 9 BL = 0 0 1 1 0 1 0 1 ASCII 5 Example : Sub AL, BL ØØ - AAM Carry → 0 0 0 0 0 0 1 1 1 1 1 1 0 1 0 0 0 1 1 0 0 0 1 1 0 0000 Clear higher nibble 0 1 0 0 → Result subtraction valid BCD of ⇓ (04 H) → Result in AL valid BCD. (00 H) → Result in AH. ØØ ØØ ØØ Algorithm : Step I : Initialize the data memory. Step II : Get the first ASCII number in AL. Step III : Get the second ASCII number in BL. Step IV : Subtract the two ASCII numbers. Step V : Using AAS, adjust result to valid BCD number. Step VI : Stop. Flowchart : Refer flowchart 54. Program : .model small .data a db 39H b db 35H .code mov ax, @data mov ds, ax mov al, a mov bl, b sub al, bl aas end ; Initialize data section ; Load number1 in al ; Load number2 in bl ; subtract the numbers and result in al ; adjust result to valid BCD number Microprocessors & Applications (UPTU) ØØ Result : AX = 0004 H Appendix B Flowchart 54 ...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

programb54 - Microprocessors& Applications(UPTU Appendix...

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