RENUMBER for Sinclair ZX-81
by David Forrest
from Your Computer, November 1983

David Forrest details a useful re-numbering program for the 16K ZX-81.


This program, written for a 16K ZX-81, will renumber a Basic program,
altering GOTO and GOSUB destinations accordingly. There is only one
proviso, and that is that all GOTO/GOSUB destinations should contain
four digits; eg. GOTO 1234. However, if your program contains
instructions such as GOTO 20, these should be altered to give four-
digit destinations. This may easily be achieved as follows:
	GOTO 2          : change to GOTO 0002
	GOSUB 200       : change to GOSUB 0200
If you do not do this, the destination will not be altered during
renumbering.

Statements of the type GOTO (X), where X is the result of a calculation,
will not be affected, provided that the variable - or expression - X is
enclosed in brackets. For example, the statement GOTO 1000*N will
probably be altered incorrectly, whereas GOTO (1000*N) will be
unchanged.

To enter the program type in the loader program in Figure 1. Line 10
will house the machine code and must contain at least 233 characters.
Now RUN the program and enter the 233 decimal codes in Figure 2, one
at a time. The loader contains a checksum routine and if you fail to
enter the codes correctly it will stop with the message "DATA ERROR".
To track down your error type in GOTO 100 and the program will print
out the codes you have entered. [No it won't - the listing routine
wasn't printed in the magazine. JimG] When the screen fills up press
CONT to continue.

When the machine code is called it will transfer itself above RAMtop
(32500) and NEW the program, so it is vital to SAVE the program first.
To do this, delete lines 20 onwards, add the lines:
	20 RAND USR 16514
	30 NEW
and then save with SAVE "RENUMBER".

Once the program has been RUN and the code is safely stored above
RAMtop you can type in or load the program you want to renumber. Enter
RAND USR 32500 to renumber.

