programb14 - Microprocessors & Applications (UPTU)...

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

View Full Document Right Arrow Icon
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 BL with byte in AL. Using SUB instruction, we will subtract the contents. The result is stored in the AL register. Using DAS instruction we will make sure that the result is valid BCD. eg. : AL = 32 BCD 0 0 1 1 0 0 1 0 BL = 17 BCD 0 0 0 1 0 1 1 1 0 0 0 1 1 0 1 1 invalid BCD, so subtract 6. DAS 0 1 1 0 0 0 0 1 0 1 0 1 = 15 BCD Invalid BCD, means if digit is greater than 9. If digit is invalid we subtract 6 to make it valid. DAS instruction (decimal adjust after subtraction), automatically adjusts to valid BCD result. ØØ Algorithm : Step I : Initialize the data memory. Step II : Get the first BCD number in AL. Step III : Get the second BCD number in BL. Step IV : Subtract the two BCD numbers. Step V : Adjust result to valid BCD number. Step VI :
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.

Page1 / 2

programb14 - Microprocessors & Applications (UPTU)...

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