← 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 12: Vibe Coding with ChatGPT

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

Download PDF
Contents

Chapter 5 of 9

Move a block one cell to the right

On a 32-column CoCo text screen, the upper-left cell has a memory address, $0400. The next cell is at $0401. In this lesson you'll ask ChatGPT to move a block between them. You can check its work one instruction at a time and tell exactly when the CoCo display changes.

Put a byte on the screen

Open Develop → Assembly Development…. For the exercise, use a spare Disk BASIC machine at its OK prompt in 32-column mode. If you need to restore that width, type WIDTH 32 at the guest prompt and press Return. Save any program you want to keep before loading another.

Make a writable copy of the screen-cell source. Choose File → Open Source… in Assembly Development and open the copy. Set the assembler target to MC6809. This is the processor the program is written for. It runs on either an emulated MC6809 or an emulated HD6309, including when your Mac itself has an Apple M-series chip.

        org     $3f00
start   lda     #$8f
        sta     $0400
        rts
        end     start

A dollar sign introduces a hexadecimal number. The first line tells LWASM, the assembler, to place the machine instructions starting at address $3F00. The word start names the first instruction. The last line tells the assembler where execution should begin.

Read the three instructions in the middle as a set of directions. LDA #$8F puts the byte $8F into A, a small storage location inside the CPU called an accumulator. The # tells the CPU to take that value directly from the instruction. STA $0400 copies A to the screen address. The display hardware interprets that byte as a solid block. RTS returns to the caller. The VCC Plus loader sets up a BASIC caller for this program.

You can find the original exercise under Quick Reference → First Program — Change a Screen Cell. That example branches to itself so you can inspect the result for as long as you like. The book's version ends with RTS so you can also practice returning to BASIC.

Follow the first two instructions

  1. Click Assemble. Open Build details and find start in the listing at $3F00. Assembling creates the binary. The CoCo starts executing it when you launch it.
  2. Choose Debug from Entry and confirm the load. The program counter, labeled PC, should read $3F00. It points at the instruction the CPU will execute next.
  3. Click Step once. A contains $8F and PC reads $3F02. At this point the program has only loaded A. Before taking the second step, locate the upper-left cell on the guest display.
  4. Click Step again. The store has executed and PC reads $3F05, the address of RTS. Look at the upper-left cell. In the debugger's mapped memory view, the byte at $0400 is now 8F. If the cell already showed a block, the byte still lets you verify the store.
  5. Choose Continue. The CoCo returns to OK. BASIC can now write to the display again, which is why the time to inspect that byte was just before RTS.

Give ChatGPT one instruction to change

In the assembly editor choose File → Local Assistant Access…, then Save Assembly Connection…. Open the connection with Add to ChatGPT and start a Work chat for this project. Give ChatGPT a job with a visible result.

Read my shared assembly source. Tell me which instruction chooses the screen cell. Propose a one-line edit through VCC Plus that moves the block one cell to the right. Keep the value and the MC6809 target the same.

In the review, look for sta $0400 changing to sta $0401. The other two instructions still have work to do. If the proposal instead changes the number after #, it changes what gets displayed. Cancel that edit and ask for the destination address to be changed. Choose Apply Edit when the proposed instruction is right. Save the practice copy.

Ask ChatGPT to assemble the current shared revision and report its entry point and any diagnostics. In the listing, place the caret on the executable rts line and choose Set Stop. Bring the disposable machine back to the 32-column BASIC prompt. You can type CLS there first to make the new block easier to see. Choose Run Shared Build… in the access panel and confirm the revised build. Each run starts with your local approval. A successful run of the earlier binary cannot verify this edit.

At the stop for the run I just started, read the source line, PC and register A. Read the three instruction bytes at $3F02 using the current debugger snapshot. What screen address does that instruction specify?

The stopped instruction should be rts, PC should be $3F05, and A should be $8F. The three bytes are B7 04 01. The assembler encoded the destination address in the last two bytes. Build 30 shares the mapped instructions and the first screen byte with the assistant. You can inspect the second screen byte yourself in the native debugger at $0401. It should read 8F. When the quiz in the next chapter puts three full lines of answers on screen, the CPU will still be doing work a byte at a time.

Choose Continue to return to BASIC. If the debugger reports that a snapshot is stale after you continue or edit, start the current build again and take a new snapshot at the stop.

Try the second processor

  1. Save the revised assembly source and anything you want to keep from guest RAM. On the spare machine, open Machine → Machine Settings… → Hardware and choose Hitachi 6309. Choose Apply and Restart… and confirm. The processor change cold-restarts the CoCo. Wait for Disk BASIC's OK prompt.
  2. Back in Assembly Development, change Target to HD6309. Ask ChatGPT to check the actual guest processor with get_machine_status, then assemble the current revision and report the assembler target. Check HD6309 in both places. If the project needs reconnecting, save its connection again before requesting the build.
  3. Set the stop on rts for this build and choose Run Shared Build… again. The earlier approval and snapshot belonged to the previous run. Inspect the new stop. Do you still see PC $3F05, A $8F, instruction bytes B7 04 01 at $3F02, and 8F at $0401 in native memory? Those are the expected results. Both processors implement these instructions with the same encodings.
  4. Choose Continue and check for the BASIC prompt. Revoke the assembly connection when you finish. To resume a practice setup that expects an MC6809, save any guest work and restore the processor in Machine Settings and the target in the editor.

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