KEYWORD is a BASIC loader and configuration program for a machine code utility that replaces the TS2068’s standard keyword entry system with a typed-keyword input mode. When enabled, the ML routine intercepts input by patching the Channel Information Area at address 26690, redirecting keyboard input so that BASIC keywords can be typed out in full rather than entered as single keystrokes. The 305-byte machine code block is loaded at address 40000, and a 51-byte startup routine is relocated to address 23300 (the printer buffer), while the 224-byte main program is ultimately moved to 23760 within the operating system workspace. The program includes a self-modifying cleanup routine that uses the TS2068-specific DELETE command to remove its own “dead weight” loader lines after installation. A custom cursor character replaces the normal K and L mode cursors when KEYWORD mode is active.
Program Analysis
Program Structure
The listing divides into three logical sections:
- Lines 1–56: A multi-screen instruction manual displayed via
PRINTand aGO SUB 100pause/copy subroutine. - Lines 100–102: Shared subroutine that prompts for a hard-copy (
COPY), tests for a stop command, clears the screen, and returns. - Lines 9900–9968: The operational core — toggling KEYWORD mode, saving the program and ML block, deleting dead weight, loading and installing the ML, and looping back to the instruction screen.
Machine Code Integration
The utility depends on an external 305-byte ML block loaded at address 40000. Installation proceeds in stages:
RANDOMIZE USR 40275(line 9962) calls a routine near the end of the loaded block that relocates a 51-byte startup routine to address 23300, which sits inside the printer buffer area.- The startup routine is called once; it carves out space at 26730 for the 224-byte MAIN program and patches the Channel Information Area at addresses 26690–26691.
- The MAIN program is then moved from 40051 to 23760, placing it within the operating system workspace so it survives
CLEARoperations (NEWorRAND USR 0reset RAMTOP).
Channel Information Area Patching
The keyword-on and keyword-off states are controlled by two POKEs to the Channel Information Area:
| State | POKE 26690 | POKE 26691 | Effect |
|---|---|---|---|
| KEYWORD ON | 208 | 92 | Redirects input to custom ML handler at 23760 (0x5CD0) |
| KEYWORD OFF | 14 | 12 | Restores standard ROM input vector (0x0C0E) |
Line 9904 additionally POKEs address 23658 with 8 to engage CAPS LOCK when KEYWORD mode is turned on, and line 9906 resets it to 0 when turning KEYWORD off, ensuring the all-caps typed-keyword entry is conveniently pre-configured.
Self-Deleting “Dead Weight” Cleanup
Lines 9940–9948 use the TS2068-specific DELETE command (not available on the standard Spectrum ROM) to remove the loader infrastructure after installation. The sequence is:
CLEAR 65337— adjusts RAMTOP to protect the installed ML.DELETE 1,200— removes the entire instruction manual (lines 1–200).DELETE 9910,9922— removes the save/delete decision lines.DELETE 9940,9999— removes the dead-weight deletion routine itself, a self-erasing final step.
After cleanup, only lines 9900–9909 remain as the toggle interface, plus the subroutine at lines 100–102 if those were not caught by the DELETE 1,200 sweep (they are within that range, so they are also deleted). The POKE method documented in line 26 becomes the only way to toggle the mode if lines 9900–9999 are ever missing.
Save/Load Sequence
Line 9912 implements a two-part save: first the BASIC program is saved with SAVE "KEYWORD" LINE 9950 to auto-start at line 9950, then after a short beep and user prompt, the ML block is saved as SAVE "KWCODE" CODE 40000,400. Line 9950 handles the complementary load sequence, clearing to 40000 and loading the code block before proceeding to install it.
Key BASIC Idioms
INPUT ... LINE q$is used throughout instead of plainINPUTto capture whole-line responses and avoid keyword-mode interference with the input cursor.- The subroutine at line 100 checks for the literal string
" STOP "(with spaces) as a secret escape hatch from the instruction loop. - Line 9916 provides a fallthrough
GO TO 9910to re-prompt when neither “y” nor “n” is entered for the save question — a simple input validation loop.
Notable Anomalies
The instruction text in line 42 states “305 bytes of ML code” and in line 50 refers to a “224-byte MAIN program,” but the save and load commands use a length of 400 bytes (CODE 40000,400). This is consistent with saving the full working area that encompasses both the relocation stub and the main payload, with some padding or additional data.
Line 9950 uses CLEAR 40000, which sets RAMTOP to 40000 before loading the ML block. This is correct for reserving the space but means any BASIC variables above that address would be lost — expected behavior given this is a clean-machine install.
Content
Source Code
1 REM KEYWORD
2 REM by Glyn Kendall
3 REM from YOUR COMPUTER,6-84
4 REM adapted for 2068 by Jack Dohany (415)321-7684
10 CLS : PRINT TAB 5;"KEYWORD INSTRUCTIONS"
12 PRINT '"1. KEYWORD allows two modes of BASIC program entry: the normal single-keystroke entry, with KEYWORD off, and ""typed-keyword"""'"entry with KEYWORD on."
13 PRINT '"With KEYWORD on, program lines"'"can be entered without using"'"SYMBOL SHIFT or Extended Mode."
14 PRINT '"2. KEYWORD can be turned off or"'"on by GOing TO 9900."
16 PRINT '"3. KEYWORD should be loaded onlyinto a ""clean machine""- that is,one that's just been turned on."
18 PRINT '"4. For technical reasons,"'"KEYWORD can only be saved right"'"after loading. Details later."
20 GO SUB 100
22 PRINT "5. RAMTOP is now ";PEEK 23730+256*PEEK 23731;"."''"The 224 bytes of KEYWORD code"'"are safely tucked away within"'"the operating system."''"KEYWORD can only be hurt by"'"the commands NEW or RAND USR 0."
24 PRINT '"BASIC or ML programs can now be"'"LOADed or MERGEd,and the presentBASIC lines can all be deleted."'"BUT if you delete lines 9900"'"-9999, then you can only switch"'"KEYWORD on or off as follows:"
26 PRINT '"ON:"'"POKE 26690,208: POKE 26691,92"''"OFF:"'"POKE 26690,14: POKE 26691,12"
28 GO SUB 100
30 PRINT "6. ***USING KEYWORD***"''"-A special cursor ( > ), is usedwhen KEYWORD is on, replacing"'"the normal K and L cursors."
32 PRINT '"-You can do everything with"'"KEYWORD on that you can with"'"it off. The only difference is"'"that keywords (such as LOAD,"'"REM, RANDOMIZE) are typed out"'"IN FULL, IN CAPS, SEPARATED BY"'"A SPACE."
34 PRINT '"-CAPS LOCK works; use it!"
36 PRINT '"-If you run into problems, try"'"CAPS SHIFT-1 (EDIT)."
38 GO SUB 100
40 PRINT "7. NOTE: Even with KEYWORD on,"'"Extended-Mode and Symbol-Shiftedkeywords can be entered as"'"single keystrokes. They can"'"also be typed out."
42 PRINT '"8. TECHNICAL DETAILS:"'"-305 bytes of ML code are first"'"loaded at 40000. The tail end"'"of that code is then called"'"(via RAND USR 40275) to move"'"the 51-byte STARTUP routine to"'"23300 (in printer buffer)."
44 PRINT '"-The STARTUP routine is then"'"called, only once; it can later"'"be destroyed, when the printer"'"is used. This routine makes"'"room for the MAIN program at"'"26730, and sets up the Channel"'"Information Area (26690,1) to"'"divert input control."
46 GO SUB 100
48 PRINT "TECHNICAL DETAILS: (Continued)"
50 PRINT '"-The 224-byte MAIN program is"'"then moved from 40051 TO 23760,"'"where it will be accessed if"'"the Channel Info Area has its"'"address."
52 PRINT '"-The original code from 40000"'"to 40305 is now dead weight."'"So it is removed, along with"'"the BASIC lines that called"'"it. This can be seen by"'"loading KEYWORD and hitting"'"BREAK during a SAVE."
54 PRINT ''TAB 9;"***THE END***"
55 PRINT ''"PS:"'"Dead Weight should be deleted."
56 GO SUB 100
58 CLS : GO TO 9964
100 INPUT "COPY? "; LINE q$: IF q$="y" OR q$="Y" THEN COPY
101 IF q$=" STOP " THEN STOP
102 CLS : RETURN
9900 REM KEYWORD
9901 REM by Glyn Kendall (YOUR COMPUTER 6-84); adapted for 2068 by Jack Dohany (415)321-7684
9902 INPUT "KEYWORD ON? (y/n)"; LINE q$
9904 IF q$="y" OR q$="Y" THEN POKE 26690,208: POKE 26691,92: POKE 23658,8
9906 IF q$="n" OR q$="N" THEN POKE 26690,14: POKE 26691,12: POKE 23658,0
9910 INPUT "SAVE KEYWORD? (y/n)"; LINE q$
9912 IF q$="y" OR q$="Y" THEN SAVE "KEYWORD" LINE 9950: BEEP .01,25: CLS : PRINT "PLEASE PRESS A KEY.": SAVE "KWCODE"CODE 40000,400: GO TO 9910
9914 IF q$="n" OR q$="N" THEN GO TO 9920
9916 GO TO 9910
9920 INPUT "DELETE DEAD WEIGHT? "; LINE q$
9922 IF q$="y" OR q$="Y" THEN GO TO 9940
9930 STOP
9940 REM DELETE DEAD WEIGHT
9942 CLEAR 65337
9944 DELETE 1,200
9946 DELETE 9910,9922
9948 DELETE 9940,9999
9950 CLEAR 40000: BORDER 0: PAPER 0: INK 7: CLS : PRINT "LOADING KEYWORD MC": LOAD ""CODE 40000,400
9960 REM INSTALL KEYWORD
9962 CLS : RANDOMIZE USR 40275
9964 INPUT "INSTRUCTIONS? ";q$
9966 IF q$="y" OR q$="Y" THEN GO TO 10
9968 GO TO 9902
Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.



