This is a cache of https://vccplus.brianholman.com/manuals/inside-the-coco-3/store/. It is a snapshot of the page as it appeared on 2026-11-21T00:01:38.838+0000.
Catch a write before it happens · Inside the CoCo 3 — Hardware and Debugging · VCC Plus
← Manual LibraryVCC Plus 3.7.1 · Reading on the web

Try the exercises in VCC Plus. Example links download files here; open them in the app to work beside the emulator.

The complete book · PDF editionBook 10: Inside the CoCo 3 — Hardware and Debugging

27 pages · VCC Plus 3.7.1 · Keep a copy to read or print.

Download PDF
Contents

Chapter 1 of 7

Catch a write before it happens

A scratch byte starts at zero. Five instructions load its address, make a value, shift it, store it and return. Suppose you stop the processor on the store. Where would you look for the answer you just calculated? The register and the memory window will give you different answers, and both will be right.

Set up the workbench

Save any work in the guest. Use a fresh Disk BASIC session with 512 KB, the MC6809 and RGB video. These choices give us one reproducible memory map for the first five chapters. The two labs also work on the HD6309 in its startup mode.

Save pixel-mask.asm to your Mac. Choose Develop → Assembly Development…, then File → Open Source… and select your copy. Choose Assemble. In Build details → Listing, find the labels shift, store, done and sample. They name three instructions and one byte of data. The listing gives their addresses even if an edit moves them.

            org     $3f00
start       leax    sample,pcr  ; X points to our one-byte sample.
            lda     #$81        ; Two end bits are set: %10000001.
shift       lsra                ; Shift right. Which bit goes into carry?
store       sta     ,x          ; Set a breakpoint here, before the write.
done        rts                 ; Return to the caller with the byte stored.
sample      fcb     $00         ; Assembling and running reloads this zero.
            end     start

LEAX puts the address of sample in X. LDA #$81 puts a value in A. In a logical shift right, bits move one place to the right, a zero enters at the left, and the old low bit moves into carry. Write the eight bits of $81 as 10000001, then try the shift on paper. Keep a separate box for the bit that falls out.

Read the stopped instruction

  1. In the assembly source, place the insertion point on line 8, labeled store, and choose Set Stop. Choose Run and accept the load if prompted.
  2. Open Debug → Show Debugger. In Inspector, find the instruction at the program counter, PC. For this listing it is $3F07, STA ,X. The comma and X mean “use the address in X.” The processor has reached the store and is waiting to execute it.
  3. Read A, X, and Carry in the register panel. The shift produced A=$40 (01000000). Carry is set because the old low bit was one. X=$3F0A, the address labeled sample.
  4. In Inspector → Memory, choose Mapped CPU. Type 3F0A in the memory address field and choose Go. Addresses down the left mark the beginnings of rows, and the headers 00 through 0F are offsets. At row 3F00, column 0A, the scratch byte is still 00. The answer is in A. RAM still holds the byte assembled by FCB $00.
The paused Inspector points at STA at $3F07. The register pane shows A=$40 and X=$3F0A. The value in column 0A of row 3F00 is 00.

Give the processor one instruction

Choose Step once at the top of the machine debugger. Follow the three values that matter here.

Read here Before Step After Step
PC $3F07, the store $3F09, the return
A $40 $40
Mapped byte at X ($3F0A) $00 $40
After one machine step the instruction arrow points to RTS at $3F09. Row 3F00, column 0A now contains 40. X still points to $3F0A.

A store copies A to the destination and leaves A available for another instruction. The PC advances by two because this encoding contains the store opcode and a second byte describing its indexed operand. If the byte in RAM already reads 40 when you first look, check the PC. At done you are one instruction later than store. Running the supplied binary again reloads the initial zero, so you can repeat the experiment.

Leave the guest paused on done. In the next chapter you can identify the location in the Mac emulator’s model of the CoCo’s RAM that actually holds this byte. For a refresher on the debugger’s arrows and source stops, revisit Book 7’s one-byte experiment.

Original VCC Plus manuals © 2026 Brian K. Holman. Third-party references retain their authors’ copyrights and licenses. Artwork notices. Edition 3.7.1; source and export identity. Printable edition: PDF source and export identity.

A closer look

Open original