Exercise 3: Explaining Three Chapter-Attribution Rows — Possible Solution ==================================================================== ROW 1: "ARRAY,X / (HL) with INC" -> cpu8bit1-4, cpu8bit1-7 ------------------------------ The 6502 version reads each array element with LDA ARRAY,X, which is zero-page,X indexed addressing exactly as cpu8bit1-4 taught it — the array lives in zero page, and X supplies a changing offset each loop pass. The Z80 version instead keeps a pointer directly in HL and reads through it with LD A,(HL), incrementing HL each pass — the register- indirect addressing cpu8bit1-7 introduced, which needs no zero-page step at all. ROW 2: "JSR/RTS and CALL/RET" -> cpu8bit1-3, cpu8bit1-7 ------------------------------ Both subroutine calls in this capstone are the first time in the entire course that either chip's real hardware stack actually gets used by a running program, rather than just being described. JSR automatically pushes a return address onto the 6502's page-1 stack (cpu8bit1-3) before jumping to UPDATE_MAX, and RTS pulls it back off; CALL and RET do the same job using the Z80's fully flexible 16-bit stack (cpu8bit1-7). ROW 3: "CMP/BCC vs. CP/JR NC" -> cpu8bit1-3, cpu8bit1-6 ------------------------------ Both subroutines need to compare a candidate value against the current MAX, and both do it by reading a Carry flag set by a comparison instruction — the status/flag registers cpu8bit1-3 (the 6502's P register) and cpu8bit1-6 (the Z80's F register) each introduced. The reason this row is worth its own dedicated line in the table is that the SAME flag, set by superficially similar instructions (CMP vs. CP), ends up meaning the OPPOSITE thing on each chip — directly exercising the flag material both of those earlier chapters built up. WHY THIS WORKS AS AN ANSWER ------------------------------ It picks three specific rows, names the exact line(s) of capstone code each one refers to, and explains — using each earlier chapter's own stated material — precisely why that code needed that chapter's concept, rather than restating the table's own wording without connecting it back to the actual code.