Routine Elimination

Author(s): Rolf Miller
Publication: Syntax
Pub Details: Syntax/Syntax ZX80 v4 n3 (Volume 4, Issue 3)
Date: March 1983
Pages: 21

Machine Language programs often use BASIC routines to load REM lines with ML code. If you PEEK the code from the REM line and POKE into protected memory for running, you can eliminate the loading routine by writing the REM line in hex equivalents to ML decimal codes.

You have to initialize REM lines to use in the loading routine anyway, so why not just write it in hex and skip the routine and all its decimal inputs? Published routines usually list the hex with the ML program, but if not, you can get it in the Appendix of the ZX81 or TS1000 manual.

This example uses the 8K Syntactic Sum decimal listing (Jun.83) converted to hex.

Before typing or loading the program, regardless of memory,

POKE 16388, 225
POKE 16389, PEEK 16389-1 and NEW

to reserve memory space for the ML routine. The 225 in the POKE is derived by subtracting 1/2 the number of characters (31) from 256.

Now enter the listing as shown. Type SAVE, RUN and write down the displayed value. Then PRINT USR the value to get Syntactic Sum. (In line 4, 16574 comes from adding the number of characters in the REM line (62) less 2 to 16514.)

Line 2 gets the first address of reserved memory, which will be the starting address of the ML routine. Line 5 PEEKs hex from the REM line, converts it to decimal, and POKEs it to reserved memory.

   1 REM 217D40ED5B0C40DD2100007CBA20087DBB2004DDE5C1C94E0600DD092318EC
2 LET A=PEEK 16388+PEEK 16389*256
3 PRINT A
4 FOR X=16514 TO 16574 STEP 2
5 POKE A,(PEEK X-28)*16+PEEK (X+1)-28
6 LET A=A+1
7 NEXT X
SYNTACTIC SUM: 11175, 8K ROM

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