Checkbook Accounts

This file is part of Byte Power February 1987 . Download the collection to get this file.
Developer(s): Kristian Boisvert
Date: 1987
Type: Program
Platform(s): TS 2068

This program implements a checkbook accounts manager, with a two-part tape structure: a BASIC loader (saved starting at line 9000) and a machine code block stored at address 60056 occupying 1778 bytes. The loader at line 9015 pulls in additional machine code via LOAD “”CODE before handing control to the machine code via USR calls. Line 30 uses PEEK 23681 (the system variable FLAGS) to detect whether the program is running for the first time, and line 46 dispatches via PEEK 65535 — a technique that lets machine code write a target line number’s low byte into the top of RAM to redirect BASIC flow. Line 9999 saves both the BASIC and machine code segments to tape, using 5e4 (50000) as the start address for the larger initial code block spanning 10056 bytes.


Program Structure

The listing is organised into several functional blocks:

  1. Lines 0–46: Bootstrap and dispatch. Detects first-run state, initialises machine code, and jumps to a dynamically determined line via PEEK 65535.
  2. Lines 50–60: Quit/cleanup routine — CLEAR 65535: NEW wipes everything.
  3. Lines 100–140: LOAD routine for named machine code file at address 60056.
  4. Lines 200–240: SAVE routine with tape verification.
  5. Lines 2000–2010: Shared filename INPUT subroutine.
  6. Lines 9000–9020: Screen loader/splash screen, used as the autostart entry point.
  7. Line 9999: Master save line — saves both BASIC and machine code to tape.

Machine Code Integration

The program relies heavily on machine code residing at high RAM addresses. Two distinct code blocks are referenced:

  • Address 60056: a 1778-byte block loaded/saved by the LOAD/SAVE routines (lines 120, 225).
  • Address 50000 (5e4): a larger 10056-byte block saved at line 9999 — this encompasses the main application logic.
  • Address 57365: entry point called via USR 57365 after a named LOAD, likely initialising the loaded code.
  • Address 50900: entry point called via USR 50900 during the bootstrap at line 45.

The REM at lines 20 notes that a “print driver” should be between 30000–49999 or 62000–65535, suggesting additional loadable modules expected to coexist in RAM.

Dynamic BASIC Dispatch via PEEK 65535

Lines 46 and 140 use GO TO PEEK 65535. This is a well-known Spectrum technique: machine code writes a BASIC line number (or its low byte) into address 65535 before returning, allowing the machine code to redirect BASIC execution to an arbitrary line without needing a fixed GO TO. It effectively gives machine code a computed GO TO capability within the BASIC program.

First-Run Detection

Line 30 tests PEEK 23681, which is the system variable FLAGS. If it equals zero the program assumes it has not yet been initialised and halts after listing line 9999 — acting as a guard to prevent the dispatch skeleton from running without the machine code payload loaded. The LET REDO=-6 assignment is an unusual preamble; REDO is not a keyword here but a numeric variable, possibly read by the machine code as a sentinel value or error-recovery flag.

Line 230 rewinds and verifies after a named SAVE, which is good practice for data integrity on tape. The autostart loader (line 9015) uses an anonymous LOAD ""CODE to pull in the main block from the next tape header automatically.

Notable Idioms and Anomalies

  • Line 9999 uses 5e4 and 5E4 as floating-point literals for 50000 — a memory-saving trick since a short-form floating-point constant occupies fewer bytes in the tokenised BASIC than the integer 50000.
  • Line 220 checks IF a$="" THEN GO TO 210 to re-prompt on empty filename, but line 2000 already enforces LEN a$>10; an empty string (length 0) would pass the subroutine check, making line 220 a necessary secondary guard.
  • The comment at line 50 misspells “PROGRAM” as “PORGRAM” — a transcription artifact in the original listing.
  • INK 7 is set before the anonymous LOAD ""CODE at line 9015, then restored to INK 0 afterward — this ensures the border/loading stripes are visible during tape load.

Content

Appears On

Tape-based magazine.

Related Products

Related Articles

When running this program, you will be asked to enter the original balance then the number of checks to be...

Related Content

Image Gallery

Checkbook Accounts

Source Code

0                                                             CHECKBOOK ACCOUNTS              WRITTEN BY KRISTIAN BOISVERT    ©1987 BYTE POWER                 
   20 REM                                                        PRINT DRIVER SHOULD BE          BETWEEN 30000 & 49999           OR BETWEEN 62000 & 65535           
   30 LET REDO=-6: IF PEEK 23681=0 THEN PRINT AT 15,0;: LIST 9999: STOP 
   40 PAUSE 300
   45 LET l=USR 50900
   46 GO TO PEEK 65535
   50 REM QUIT PORGRAM
   60 CLEAR 65535: NEW 
  100 REM LOAD
  110 GO SUB 2000
  120 LOAD a$CODE 60056
  130 LET l=USR 57365
  140 GO TO PEEK 65535
  200 REM SAVE
  210 GO SUB 2000
  220 IF a$="" THEN GO TO 210
  225 SAVE a$CODE 60056,1778
  230 PRINT AT 10,4;"REWIND TAPE TO VERIFY...": VERIFY a$CODE 
  240 GO TO 130
 2000 INPUT "FILE NAME:"; LINE a$: IF LEN a$>10 THEN GO TO 2000
 2010 RETURN 
 9000 INK 0: PAPER 7: BORDER 7: CLEAR 29999: PRINT AT 8,7;"CHECKBOOK ACCOUNTS"
 9010 PRINT AT 10,2;"Written by KRISTIAN BOISVERT";AT 12,8;"©1987 BYTE POWER"
 9015 PRINT AT 15,0;"Still LOADING...": INK 7: PRINT AT 18,0;: LOAD ""CODE : INK 0
 9020 GO TO 10
 9999 SAVE "CHECKBOOK" LINE 9000: SAVE "CHECKBOOK"CODE 5e4,10056: VERIFY "CHECKBOOK": VERIFY "CHECKBOOK"CODE 5E4,10056

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.

Scroll to Top