Step 2 of 2
Add and Store the Result
Now finish the program. Add the two numbers and store the answer at 2002H.
The loading code from the previous step is already in the editor, so you only need the arithmetic and the store.
The one thing: Arithmetic always goes through
A, and the carry flag is not an error — it is the ninth bit of an answer that outgrew the register.
What is being checked
2002Hholds the sum- The carry flag reflects whether the addition overflowed
2000Hand2001Hstill hold the original numbers- The program reaches
HLT - You reach memory through
HL, and not withLDAorSTA
About the carry
FFH + 02H is 101H, which does not fit in eight bits. The accumulator keeps
the low byte, 01H, and the carry flag records that a ninth bit was produced.
The carry is not an error. It is the processor telling you the true answer was
larger than one register can hold, and it is what makes multi-byte arithmetic
possible later on.
You are not asked to do anything about the carry here. Just do not clear it: some instructions leave the flags alone and others do not, and the check will notice.
Progress is kept for this tab only. Sign in to save it across devices.