This program loads and demonstrates a machine code routine at address 65195 that displays the current BASIC variables in memory. The setup clears memory above address 65194 with CLEAR before loading 173 bytes of machine code via LOAD “” CODE. Lines 50–60 define sample variables (integers, a string, and a FOR–NEXT loop counter) to give the routine something to display. The demonstration concludes by calling RANDOMIZE USR 65195 to invoke the machine code, and line 100 saves both the BASIC loader and the machine code block for later use.
Program Analysis
Program Structure
The program is a loader and demonstration shell for a machine code variable-listing utility. It divides naturally into three phases:
- Setup (lines 10–47): Clears RAM above 65194, loads 173 bytes of machine code to address 65195, and prints usage instructions with a keypress pause.
- Demo (lines 50–64): Creates representative variables — two numeric variables, a string, and a FOR–NEXT loop — then immediately calls the machine code routine to display them.
- Save (line 100): Persists both the BASIC program (with auto-run at line 10) and the raw machine code block to tape.
Memory Layout
The choice of address 65195 is deliberate: it sits near the very top of the 65535-byte address space, leaving the machine code block well above any typical BASIC program or its variables. CLEAR 65194 moves RAMTOP to 65194, protecting the 173 bytes at 65195–65367 from being overwritten by the BASIC system.
| Address | Content | Size |
|---|---|---|
| 65194 | RAMTOP (CLEAR boundary) | 1 byte |
| 65195 | Machine code routine entry point | 173 bytes |
| 65368 | Top of used RAM | — |
Key BASIC Idioms
CLEAR 65194beforeLOAD "" CODE 65195,173is the standard idiom for safely reserving a high-memory machine code block before loading it.PAUSE 4e4(line 47) pauses for 40,000 frames (~5.5 minutes at 50 Hz, effectively indefinite), waiting for the user to press a key — a common substitute for a keypress wait whenINKEY$polling is not needed.RANDOMIZE USR 65195(line 64) is the conventional method for calling a machine code subroutine from BASIC; the return value of USR is discarded by RANDOMIZE.
Demo Variables
Lines 50–60 deliberately exercise several variable types to showcase what the machine code routine can display:
a=1andb=100— simple numeric variables.d$="hello"— a string variable.FOR i=1 TO 5: NEXT i— a completed FOR–NEXT loop; afterNEXT iexhausts the loop,iremains in the variables area as a FOR variable descriptor, which the routine can display.
Save Strategy
Line 100 performs two sequential SAVE operations. SAVE "Varslist" LINE 10 saves the BASIC program with an auto-run directive at line 10, so reloading it will automatically re-run the loader. SAVE "vars" CODE 65195,173 saves the raw machine code block independently, allowing advanced users to load only the binary into their own programs without the demonstration shell.
Notable Anomalies
- Line 65 (
STOP) prevents execution from falling through to line 100, ensuring theSAVEcommands only run when explicitly typed or called — a standard guard pattern. - The instructional
PRINTstatements in lines 20–45 contain hard-coded spaces for formatting, which is typical of programs intended to display cleanly on a 32-column screen. - The variable name
d$skipsc$, which is unremarkable but slightly unusual for a sequential demonstration.
Content
Source Code
10 CLEAR 65194: LOAD "" CODE 65195,173
20 PRINT " To see your variables enter: RAND USR 65195"
30 PRINT "These program lines can be elim-inated, and your own program now loaded."
40 PRINT "Here's an example:"
45 PRINT "Hit enter to continue."
47 PAUSE 4e4
50 LET a=1: LET b=100: LET d$="hello"
60 FOR i=1 TO 5: NEXT i
64 RANDOMIZE USR 65195
65 STOP
100 SAVE "Varslist" LINE 10: SAVE "vars"CODE 65195,173
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.
