REM Generator

Date: 1984
Type: Program
Platform(s): ZX81, TS 1000

A 68-byte machine-code routine, kept above a lowered RAMTOP at 32699, meant to build a line-0 REM of any length to hold machine code, so you do not have to type hundreds of characters after REM. A short BASIC program asks how many bytes you want, POKEs the count into the routine and calls it.

The routine is used by lowering RAMTOP to 32698 (POKE 16388,186, POKE 16389,127 and NEW), entering the 68 bytes at 32699 with the loader, and then running the REM-making program. As printed, the routine reads its byte count from 16450 (in the printer buffer) while the BASIC POKEs the count into the routine itself, so it fills memory instead of making the REM. It is part 2 of the newsletter’s unsigned machine-code series.

Published in Sinc-Link early 1984 (Vol. 2 No. 2) (Machine Code Programming (part 2)).

Related Articles

Machine language programming tutorial.

Image Gallery

Source Code

Loader:
10  SCROLL
20  PRINT "ENTER STARTING ADDRESS"
30  INPUT X
40  SCROLL
50  SCROLL
60  PRINT "ENTER YOUR MACHINE CODE"
70  SCROLL
80  SCROLL
90  INPUT Y
100 POKE X,Y
110 PRINT X;"'"; PEEK X
120 LET X=X+1
130 GOTO 80

REM Generator machine code (enter at 32699):
237, 75, 66, 64, 205, 231, 2, 197, 3, 3, 197, 1, 6, 0, 42, 41, 64, 9, 34, 41,
64, 33, 125, 64,  205, 158, 9, 35, 112, 35, 112, 35, 193, 113, 35, 112, 35, 54,
234, 35, 54, 118, 193, 197, 205, 158, 9, 193, 197, 35, 54, 61, 11, 120, 177, 32,
248, 193, 42, 41, 64, 9, 34, 41, 64, 195, 7, 2

REM Generator BASIC:
10  PRINT at 10,0; "HOW MANY BYTES FOR THE REM STATEMENT?"
20  INPUT X
30  POKE 32711, X- INT (X/256) * 256
40  POKE 32712, INT (X/256)
50  RAND USR 32699
60  CLS
70  LIST 0

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