This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Microprocessors &amp; 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
- Spring '11