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: Literal 8085: (D,E)=(00H,79H) and (FFH,13H). Intended subtraction output for first pair is (00H,19H), requiring a carry-clearing correction. (no official key was published)
1. For the first pair S2 has A=18H,CY=1. JC goes to S3 and D remains 00H. INR A makes A=19H but, on 8085, does not change carry. Therefore CY is still 1.
2. The following DAA uses that retained carry and adds 60H, producing 79H. MOV E,A therefore stores E=79H. It is incorrect to report literal E=19H while silently treating INR as a carry-clearing operation.
3. For the second pair S2 has A=86H,CY=0, so JC is not taken. MOV E,A stores 86H; then A=99H−86H=13H and MOV E,A stores 13H. The result is nonzero, so JZ is not taken and D becomes FFH. Final pair is (FFH,13H).
4. The apparent intent is a signed magnitude: D=00H for nonnegative B−C, FFH for negative, and E the BCD magnitude. That intended first result would be 19H. Replacing INR A by ADI 01H clears the inherited carry for these reachable values and gives the intended result after DAA; this is a proposed repair, not text present in the source.
5. The paper’s clear INR resolves the mnemonic but not the retained-carry defect. Both literal and intended interpretations must remain visible until an authoritative erratum is available.