AUTOLINE

Date: 198x
Type: Program
Platform(s): TS 2068

AUTOLINE is a machine code utility that automates line numbering in the BASIC editor, modifying the TS 2068’s line-number increment behavior. The machine code block of 250 bytes is stored starting at address 65024, just below the top of the standard 48K RAM. Three key addresses are documented in the BASIC loader: POKE 65192 sets the step value between auto-generated line numbers, RANDOMIZE USR 65120 activates the routine, and RANDOMIZE USR 65124 deactivates it. The program saves itself in two parts — a BASIC loader and a separate CODE file — allowing the machine code to be reloaded independently of the BASIC program. The CLEAR 65024 in line 110 protects the machine code area from being overwritten by BASIC’s memory manager before the CODE file is loaded.


Program Structure

The listing is a self-contained loader/installer for a machine code routine. It operates in two logical phases:

  1. Information display (lines 10–60): Prints usage instructions and waits for a keypress via PAUSE 0.
  2. Installation (lines 70–80): Calls RANDOMIZE USR 65024 to execute the machine code, then halts.

Lines 90–100 handle the two-part save process, and line 110 serves as the bootstrap entry point used when loading from tape — it sets up protected RAM, loads the machine code, and restarts the display loop.

Memory Layout

AddressPurpose
65024Start of machine code block (entry point / installer)
65120USR address to activate auto-line numbering
65124USR address to deactivate auto-line numbering
65192POKE target: configures the line number step value
65024 + 250End of machine code block (250 bytes total)

Placing the code at 65024 puts it near the very top of 48K RAM, well above the typical BASIC and variable area, minimizing interference with user programs.

Save and Load Strategy

Line 90 saves two separate files: a BASIC autostart file (AUTOLINE with LINE 110) and a raw machine code file (autoline C) covering the 250 bytes from address 65024. On reloading, line 110 issues CLEAR 65024 before LOAD "autoline C" CODE, which raises RAMTOP to protect the target address range from BASIC. This is the standard safe-load idiom for machine code residing in high RAM.

Key BASIC Idioms

  • PAUSE 0 at line 60 halts execution indefinitely until any key is pressed — an efficient keypress-wait without polling INKEY$.
  • RANDOMIZE USR 65024 at line 70 calls the machine code entry point; the return value is discarded by RANDOMIZE, making it a clean way to invoke Z80 code without requiring a function-like return value.
  • The REM at line 10 uses embedded character codes (\{20}\{1} and \{20}\{0}) to switch ink colors within the remark, providing a styled title without affecting program logic.

Machine Code Block

The 250-byte machine code block is entirely external to this listing (saved as autoline C). From the documented addresses, the block contains at least three distinct entry points: the installer at 65024, an activate hook at 65120, and a deactivate hook at 65124. The POKE address at 65192 (168 bytes into the block) holds the configurable step value, suggesting it is a single byte used as an immediate operand or a data cell read by the line-increment routine. The routine most likely patches the ROM keyboard handler or editor loop to inject incremented line numbers automatically when the user starts a new BASIC line.

Anomalies and Notes

  • Line 80 and line 100 both contain STOP, acting as clear barriers between the run-time and save-time sections of the program, preventing accidental fall-through into the SAVE commands during normal operation.

Content

Appears On

Related Products

Related Articles

Related Content

Image Gallery

Source Code

  10 REM \{20}\{1}AUTOLINE\{20}\{0}
  20 PRINT "POKE 65192 WITH STEP REQUIRED"
  30 PRINT "RANDOMIZE USR 65120 TO TURN ON"
  40 PRINT "RANDOMIZE 65124 TO TURN OFF"
  50 PRINT "NOTE THESE NUMBERS AND          PRESS ANY KEY WHEN READY"
  60 PAUSE 0
  70 RANDOMIZE USR 65024
  80 STOP 
  90 SAVE "AUTOLINE" LINE 110:SAVE "autoline C"CODE 65024,250
 100 STOP 
 110 CLEAR 65024:LOAD "autoline C"CODE :GO TO 10

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

People

No people associated with this content.

Scroll to Top