Data Representation & Arithmetic



Shared context
B and C contain packed-BCD values 00…99. Program: S1: MVI A,99H; MVI D,00H; SUB C; ADD B; DAA; S2: JC S3; MOV E,A; MVI A,99H; SUB E; MOV E,A; JZ S4; MVI D,FFH; JMP S4; S3: INR A; DAA; MOV E,A; S4: … . Interpret the latter as INR for the architectural analysis.
Answer & solution
Answer: A=18H (CY=1) and A=86H (CY=0), respectively. (no official key was published)
1. All shown register inputs are packed BCD, so decimal 44 means byte 44H, not byte 2CH. MVI D does not change the accumulator or arithmetic flags.
2. First pair: 99H−25H=74H. ADD 44H gives B8H, with no low-nibble auxiliary carry (4+4=8). DAA corrects the invalid high decimal digit by adding 60H, producing 118H: A=18H and CY=1 at S2.
3. Second pair: 99H−46H=53H. ADD 33H gives 86H, already valid BCD, with no carry or auxiliary carry. DAA makes no correction: A=86H and CY=0.
4. The decimal interpretation is 99−25+44=118, whose lower two digits are 18 with a carry, and 99−46+33=86 without a carry. This part ends before INR and the second DAA, so the later program defect does not change these answers.