This is a cache of https://vccplus.brianholman.com/manuals/programming-in-coco-basic/machine-room/. It is a snapshot of the page as it appeared on 2026-11-21T00:00:54.983+0000.
Where BASIC meets the machine · Programming in CoCo BASIC on the Color Computer 3 · 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 3: Programming in CoCo BASIC on the Color Computer 3

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

Download PDF
Contents

Appendix B

Where BASIC meets the machine

When you ask BASIC how many supplies are left, you use the name S. Somewhere inside the CoCo, the interpreter keeps bytes for that number. In this little tour you can look at one of those bytes without changing it.

Find a value and its address

Open ADDRESS.bas. Line 20 puts the number 42 in A. The next three lines ask different questions about the same variable. Which line do you expect to print 42?

10 WIDTH 40:CLS
20 A=42
30 PRINT "VALUE";A
40 PRINT "ADDRESS ";HEX$(VARPTR(A))
50 PRINT "FIRST BYTE";PEEK(VARPTR(A))
60 END

The output labeled VALUE is 42. The ADDRESS is where BASIC put the variable’s data this time. HEX$ displays the address in hexadecimal, a number system with sixteen digits per place. After 9 its digits are A, B, C, D, E and F. Your address can include letters.

The last line with PRINT asks for one byte, starting at that address. In the supplied exercise we saw address 2667 in hexadecimal and first byte 134 in decimal. BASIC stores this numeric variable as several bytes. Reading just the first byte gives a piece of the stored number. To learn the value of A while debugging, ask for A in Watches. The whole value is already there.

Use the address reported in your session when inspecting memory. Adding program lines or variables can move the data, even if A still holds 42. The VARPTR, HEX$ and PEEK entries describe the three operations in the listing.

Follow the workspace

Think of BASIC’s workspace as part of RAM that the interpreter manages on your behalf. It keeps the numbered program, variables and space for strings there. MEM reports the space BASIC still has available. The RAM badge at the top of the emulator reports the capacity of the emulated machine. A program, a screen, and the interpreter can occupy different pieces of that machine.

The processor uses 16-bit addresses: it can name 65,536 byte positions in its current view. The CoCo 3 can contain much more RAM than this. Its memory management unit, or MMU, maps blocks of physical memory into the processor’s view. In the debugger this is the distinction between a CPU address and a physical address. It explains why a number from VARPTR only describes the current arrangement.

PEEK reads from the current address space. POKE writes a byte there. A write can change a variable, an instruction, or a hardware setting, depending on the address. Use a separate practice session for an experiment that writes to memory. The CoCo 3’s LPEEK and LPOKE accept long addresses up through 524287. That BASIC interface covers the first 512 KB, including on a machine configured with more RAM.

Hand control to machine code

BASIC lines are stored in a form that the interpreter reads. A machine-language program contains instructions that the processor executes. Each has its own loading path. A disk BASIC program such as the one in the export lesson can be loaded by name and started with RUN. LOADM brings machine-code blocks from disk into memory. EXEC transfers control to an entry address. The assembler and the program’s loading instructions tell you the right address.

A machine routine can also do one job for a BASIC program. DEF USR assigns a routine’s entry address to a USR slot. USR calls the routine with an argument. The caller and routine have to agree on how data goes in and how the result comes back. For an ordinary BASIC subroutine like the landing routine, GOSUB and RETURN already handle the trip.

To explore CPU instructions on the Mac, open Develop → Assembly Quick Reference…. For loading old programs, remember that DLOAD once expected a compatible host on a serial connection. VCC Plus provides native source opening and emulated media loading; select the one appropriate to the file you have.

Historical sources and credits

  • Tandy Corporation. Tandy Color Computer 3 BASIC Quick Reference Guide. 1986. Commands, pp. 2–17; functions, pp. 18–22; operators, p. 23; error codes, p. 27. The short format of the lookup entries follows the same practical idea: a reader at the keyboard should be able to find one operation quickly.
  • InterTAN Canada Ltd. Color Computer Disk BASIC Quick Reference Guide. 1987. Disk commands, pp. 3–8; disk errors, p. 9. Useful for comparing sequential files with direct-access records.
  • Krupski, Roger, Joe Scinta, Greg Miller, and Colin J. Stearman. RGB-DOS. Ken-Ton Electronics. COPY, DRIVE, DOS and RUNM, PDF pp. 6–8. Page references here use the pages of the scan.
  • Lindner, Tim. CoCo SDC User Guide. 4th ed., February 2023. Based on the original manual by Brian Blake; CoCo SDC hardware and software by Darren Atkinson. Drive status and mounting, pp. 9–10; directory and startup operations, pp. 11–12.

The Color Computer Archive preserves historical documentation that informed this book. The lessons and programs here were written for VCC Plus. The printed sources describe period equipment or DOS extensions; the flight exercises, screen captures and Mac controls show how to work with this emulator.

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