RENUMBER

by Matthew Homer



This machine code program will renumber the lines in your programs and

alter any affected statements accordingly.



Here is a renumber program written in machine code for the Spectrum.

It renumbers all lines and alters GOTO, GOSUB, RESTORE, LIST, LLIST,

RUN and LINE statements accordingly. The program takes up just over

2/3K at the top of memory. It is as fast as any commercially available

renumber program, although it does a bit extra, by renumbering all

commands which can have line numbers as their parameters (ie. not just

GOTO and GOSUB commands).



We give you the listings for both the 16K and 48K versions. Each

listing will place the Renumber machine code above RAMtop and below

the user defined graphics for the Spectrum (the machine code can only

go into these locations; it is not relocatable). Each listing

incorporates a routine for testing its own DATA statements which can

be used by entering GOTO 700. This routine takes 30 seconds to run and

performs three tests on the data in order to determine if the data are

correct (see 16K listing). There is also a routine for saving the

machine code.



Get typing



Once you have typed in the program and are satisfied that the data are

correct, you may run the program. The machine code is then ready to

use and you will not require the BASIC any more (it is only needed

initially, to place the machine code in memory). You may save the

machine code by entering GOTO 500 (Microdrive) or GOTO 600 (tape). I

would suggest that you also save the BASIC, just in case.



Note



Whenever you want to load the renumber code, you must enter CLEAR

64664 (48K) or CLEAR 31896 (16K) before loading, otherwise the

Spectrum will crash.



Up and running



To run the renumber program, simply enter RANDOMIZE USR 64665 (48K) or

RANDOMIZE USR 31897 (16K). If there Is a program. to renumber, the

prompt: Enter renumbering step (MAX = number)



0000



will appear. Type in the number (if you make a mistake type it in

again - you will notice that the number will rotate from right to left

as you press each key). Press Enter when you have finished or "H" to

exit. After a few seconds or milliseconds depending on the size of

program (a full 40K program can take up to 15 seconds to renumber),

the computer will be returned to BASIC. You will notice that your

previously alphabet-soup-like line numbers are now neat and

structured. GOTO, GOSUB, LIST, LLIST, RESTORE,RUN and LINE commands

are also altered to suit these new line numbers, although if these

commands have no parameter or have a variable as a parameter, they

will be left alone. If any of these commands point to a line number

beyond the end of the program (GOTO 9000 when the last line in the

program is 7000), they will be changed to point to line 9991. This is

the largest prime number available for line numbers and therefore

unlikely to be occupied after renumbering; you can then put a STOP

statement in line 9991 to trap such GOTO and GOSUB commands.

