programb40 - Microprocessors & Applications...

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 DocumentRight 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 : We have a number given. Initially, we will count the number of 1s in that number. For this we will rotate the contents of number bit by bit to right, alongwith carry. If carry = 1 then increment the count for number of 1s. In this way we will count the number of 1s. Then AND the number of 1s with 01 H. If number is Odd, ZF = 1. For even number ZF = 0. Move DL = 00 if number is even, else store DL = 01 H if the number is 0dd. Display the result. Algorithm : Step I : Initialize the data segment. Step II : Initialize counter = 16 for number of bits = 16. Step III : Get the number Step IV : Rotate the number by 1 bit to right alongwith carry. Step V : Check if carry = 1 ? If yes goto step VI else goto step VII. Step VI : Increment count for number of 1s. Step VII : Decrement counter. Step VIII : Check if count = 0 ? If not, goto step IV....
View Full Document

Page1 / 2

programb40 - Microprocessors & Applications...

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