14 the Basic initialisation routines wHen the ZX Spectrum is switehed on, must be reset before your program can be run. item (ii) above does this for you. The use of two stacks helps make the MONITOR invisible to your machine code program. . . : Having run, the program will have encountered the Breakpoint at address 6009, and have displayed ''Press BREAK for Monitor'"'. Press tho BREAK/SPACE key (shifted or unshifted) to access the MONITOR. The first operation after a Breakpoint should always ba to replace the correct byte values to the addresses where the break occurred. ' K — Break Restore s This command restores the correct values into the three bytes overwritten by the Breakpoint command. Type K The screen will show K 6009 and will serol! up one line, displaying the prompt on the bottom line, There is no need to type ENTER. Using the M command, verify that the original codes have been replaced in addresses 6009 to 60OB, Only one Breakpoint can be entered at any time, as there is only enough room to store one address and three data bytes, so a Break "Restore (K) command must be executed before the next Breakpoint (B) is defined, and it is recommended that a Break Restore (K) command is keyed immediately after a Breakpoint has been encountered, h If you enter an incorrect breakpoint with the B command, type K im mediately afterwards to restore the original values to the incorrect breakpoint address, and then re-type the Breakpoint. The K command can only restore the last entered Breakpoint. Let us now inspect the CPU registers, to make sure that the program is working as we expect. R — Display values in CPU registers 1 the prompt is not visible on the bottom line of the screen, type X, otherwise e | mo Type R The screen scrolis up, automatically displaying the CPU register contents thus: k > ; IR. "a ZFSA a'F" i 0044 Bre"? / 1721 D'E"' " . 369B BPA? 2758 AF OF5A EC OODOO DE OO00O HL O00O IX OZDA IY SCZA SE bE?3 PC 6009 k There is no need to type ENTER. As you will see, the Program Counter contains 6009, the address at which the Breakpoint occurred. The BC, DE and HL register pairs will all contain 0000. In this example, these are the oniy registers that we are interested in. The CPU registers are displayed with their contents shown in Hex, and the values in the registers are stored in RAMat the addresses shown in Appendix A. When the MONITOR is entered from a Breakpoint, the values of the registers immediately prior to the Breakpoint are stored in these memory locations, so that the operation of your routine can be checked, and corrections to the routine, or the register contents can be made before continuing. J Any changes to the CPU register values stored in RAM during a Breakpoint only take effect after a Jump (J) or Breakpoint Continue (C) command has been executed. Having a) encountered one Breakpoint, b) restored the correct values after the break, and c) verified that the CPU registers have their correct values, we will now enter another Breakpoint, and continue the routine. ;