Similar questions 2 more →
Instructions & Addressing Modes



Answer & solution
Answer: B (no official key was published)
1. The C test is before the decrement: C=8,7,...,1 each enters the body, while C=0 exits. There are exactly eight rotations.
2. Write the original bits as a7...a0. The successive carry outputs are a0,a1,...,a7. Any incoming carry sits at the top and cannot emerge until a ninth rotation.
3. Only JC Y reaches ADD B,#1. Thus B increases once for every outgoing 1 and never for an outgoing 0. Starting from zero it ends at a0+...+a7, the population count: B.
Solution: The counter C starts at eight and the loop performs exactly eight one-bit right rotations through carry. The carry tested immediately after the kth rotation is the kth original low-to-high bit of A. Newly inserted carry bits cannot reach the outgoing low position during these eight iterations. B starts at zero and is incremented exactly when the outgoing bit is one, so B is the population count of the original A, option B.