Chapter 6 of 7
Recognize a device on the bus
A store instruction gives the machine an address and a value. At $3F0A, a RAM chip kept the value. What listens at $FFB6? Run a program whose choice you can see on the monitor, then find the instruction that made the choice visible.
Catch a write to the GIME
Start at the prompt in a fresh 512 KB Disk BASIC session with RGB video. In Develop → Assembly Development…, open File → Hello World — Earth or Mars or save the assembly listing. Set a breakpoint on greet, at STB BG6. Run, click the CoCo screen, and press 2 for Mars. The program has chosen a sentence but has yet to print it.
- In Debug → Show Debugger, choose Inspector. PC is $3F22 in the supplied build and B contains $25. Find the definition of BG6 in the source. It names $FFB6, GIME palette slot 6 (the seventh slot, counting from zero).
- Inspect Mapped CPU memory at FFB6. The low six bits read $09 in the fresh practice setup. Step one machine instruction. PC advances to $3F25 and the low six bits now read $25, the value B supplied.
- Continue and read Hello Cold Red Dot World! on a red background. How did the letters acquire that color? The next instructions set a text attribute that selects slot 6 as the background. The output routine writes the characters. You can follow that sequence in Earth or Mars.
The CoCo 3’s GIME chip controls both the palette and the mapping from CPU addresses to RAM. You met its memory mapping earlier. This time the CPU used an address on its bus to select a color register. An address is how the CPU reaches something. Knowing the type of hardware at that address tells you what the write means.
Read the switch and the running connections separately
In the practice machine, open Cartridge → Cartridges…. Confirm that the FD-502 occupies Multi-Pak slot 4, the other three slots are empty, and both Live routing indicators show slot 4. Leave the disk idle. This experiment keeps the ROM accessible while briefly choosing an empty slot for floppy I/O.
At the BASIC prompt enter POKE &HFF7F,&H32. Watch the live ROM selection stay on 4 while I/O ports changes to 3. Before doing anything with the disk, enter POKE &HFF7F,&H33 to restore both live connections to 4. The startup selector stays at 4 throughout. See the two selections in the cartridge window.
Why $32? The two selector fields count from zero. In $32, the high field contains 3 (the fourth slot for ROM) and the low field contains 2 (the third slot for I/O). Changing the low field back to 3 reconnects the controller’s ports. We learned the result by watching the routes. In the debugger, mapped $FF7F shows a dash because the inspector does not perform a guest read there. A dash means unavailable. The guest can still write the register, as you just proved.
Follow the interruption in a trace
If the pixel-mask recording is still in Trace, select it. Otherwise, repeat the short capture or use the figure below. A hardware IRQ can arrive at a different point on another run. Read the Event column before interpreting a PC as an instruction that ran.
| In this capture | What happened |
|---|---|
| IRQ requested, PC $3F07 | The request arrived while the next application instruction was the store. |
| IRQ servicing, PC $3F07 | The CPU accepted it. An IRQ request can instead be masked, so the first row alone cannot establish that a handler ran. |
| IRQ vector, PC $FEF7 | The CPU obtained the handler entry. Inspect the mapped bytes at $FFF8 and $FFF9. The pair FE F7 is the address $FEF7, high byte first. |
| Instruction, PC $FEF7 | The handler’s first instruction branches to $010C. The following jump leads into Disk BASIC’s IRQ code. |
The selected row describes the vector event. Its zero in the instruction-cycles field does not time the entire interrupt. Look farther down the capture. The instruction RTI restores the saved context and its next PC is $3F07. The four-cycle STA ,X finally runs there with A=$40. Compare with the deliberately triggered software interrupt, where the program controls the instant of entry.
Some device reads have effects of their own. Disk BASIC’s handler in this trace reads a PIA, the chip handling peripheral I/O. The debugger shows a dash at mapped $FF02 to avoid doing an extra read merely because its memory window is open. Use captured instructions, registers and device indicators to learn what the guest did.
Read the register set for this CPU
Both guest CPUs reached the same palette store and responded to the same Multi-Pak writes. A, B, X, Y, U, S, PC, DP and CC give you a common set of landmarks. On an HD6309, the Inspector also offers E, F, V and MD. E and F make up W, just as A and B make up D. Read MD when comparing operating modes. The HD6309 practice runs in this book use its startup emulation mode. Book 9 lets you watch W in a transfer and inspect a native-mode change.