[comp.sys.atari.8bit] Renumber.BAS -- fast renumber, machine language

fseipel@hpuxa.ircc.ohio-state.edu (Frank E. Seipel) (03/09/91)

From A.N.A.L.O.G. Computing, Issue #27, February 1985

Instant Renumber

16K Cassette or 24K Disk

by Angelo Giambra

 How would you like to instantly renumber any BASIC program by merely
pressing the START key on yor computer console? Instant Renumber will load
into your computer a machine language renumber utility, which will jump
into action every time you press the START key. Here's how to use it.

                                Loading it in.

 First, key in Instant Renumber, making sure to key the data statements
accurately. Save it to cassette or disk before running it. There are two
reasons for this: first, if you made any errors keying in the DATA
statements, your system will probably lock up when you run the program.
Second, after the program runs correctly, it self-destructs. I'll explain
why later.
 After you've saved the proram, run it. Your screen will go black for about
thirty seconds while the DATA statements are being read into memory. Finally,
you will see a message similar to the following on your screen:

                         RENUMBER INSTALLED
                         AT DECIMAL ADDRESS
                               7292

 On your computer, this number may differ. Jot this address down on a piece
of paper for reference. I'll explain why later in this article.
 Instant Renumber is now resident. It will remain on the job until you press
SYSTEM RESET or turn off your computer.

                                  Using it.

 To activate it, load any BASIC program into memory. List a few lines of it
on your screen. Now press the START key on your console. The message INSTANT
RENUMBER appears on your screen, and a second later the READY prompt appears.
Your program has just been renumbered in increments of ten.
 This renumber utility resolves all references to line numbers in statements
such as GOTO, GOSUB, IF...THEN, etc.
 If the utility encounters no problems, it simply ends with the READY prompt.
Otherwise, after resequencing your program, it reports problems to you in the
following manner. Suppose you have this program line:

                              50 GOSUB 1000

 If Line 1000 is nonexistent, Instant Renumber reports it this way:

                                 NF 50

 This means that, on Line 50, the target address (1000) was not found. You
must correct incorrect line numbers manually.

 Symbolic references are handled in a similar manner. Consider this line of
BASIC:

                             20 GOTO NEXTLINE

 Instant Renumber will report this as follows:

                                 SR 20

 This means that, on Line 20, there is a symbolic reference. You'll have to
adjust these yourself.
 Not all messages indicate an error. Sometimes we turn off the TRAP statement
by assigning it to a non-existent number, such as TRAP 40000. The Instant
Renumber program will report lines which use this convention with an NF
message, although they are not truly errors.

 Never activate Instant Renumber until you have listed the program to the
screen. It is not necessary to list the entire program. Just type in LIST,
press RETURN, then immediately press the BREAK key. You must do this,
because BASIC keeps a set of internal pointers which tell it where program
lines begin and end. When you add or delete lines, BASIC sometimes does not
update its pointers until several changes have been made. Instant Renumber
needs these pointers to be current. Listing the program forces BASIC to do
an update.
 Sometimes you may want to renumber your program in increments other than
ten. Instant Renumber may be activated manually. Earlier, I told you to jot
down the decimal address that appears on the screen after the utility
installs itself. To manually run it, key in a USR statement like the
following:

                            X=USR(7292,100,5)

 In this example, 7292 represents the decimal address you jotted down.
Remember, your number may differ. The next number, 100, is the base number.
It tells Instant Renumber that you want your first program line to be
resequenced as Line 100. The last number, 5, tells the utility to increment
each successive line by 5.

                            How it works.

 Here's how the program works. It first installs Instant Renumber in low
memory. This varies on different systems, depending on -- among other things
-- whether you have cassette or disk. It protects the utility by altering the
LOMEM pointer to point to the end of the machine language code. That way,
BASIC will never use the memory occupied by Instant Renumber. That's why the
program vanishes after you run it. Altering the LOMEM pointer forces BASIC
to realign all of its internal pointers, and it loses track of where the
current program is!
 Next, the program activates a vertical blank interrupt routine, which also
resides in low memory. A VB interrupt routine is a series of instructions your
computer executes every sixtieth of a second. You don't know its running,
but it is always there. The VB interrupt is constantly checking to see if
you have pressed the START key. If you have, it activates Instant Renumber.
 One final note for those of you with disk drives. When you key in DOS,
the DUP.SYS file begins to load into the same area of memory occupied by
the VB interrupt routine. Normally, this would cause the system to lock up.
The program guards against this by providing an automatic SYSTEM RESET the
first time you key in DOS. Instead of going to the familiar DOS menu, your
screen will flicker, and you will remain in BASIC. Simply key in DOS again to
go to the DOS menu.

                               Fast relief.

 Because Instant Renumber is written entirely in machine language, it is
incredibly fast. Even programs which exceed 500 lines are renumbered in
less than two seconds.
 I think you'll find Instant Renumber an invaluable tool. Renumbering your
BASIC program was never so easy.

uuencoded.

------------------------cut here-----------------------------
begin 0666 RENUMBER.BAS
M     3D!.@&Z ;X6U!;)041$TD%$1%*Q042R042Q3$]-1<U!34]53M1(24U%
MS='!0T]53M1,STC)3T9&4T7424Y35$%,S-@              0         "
M          ,         !          %          8         !P      
M   (          D         "@         +          P         #0  
M       .          \       !D " @ $%34T5-0DQ%4B!214Y534)%4B!5
M5$E,2519FVX %Q< 0ED@04Y'14Q/($=)04U"4D&;>  &!@";@@ C(P!324Y#
M12!42$4@4D5.54U"15(@551)3$E462!)4YN, "(B $Y/5"!&54Q,62!214Q/
M0T%404),12P@0D%324.;E@ C(P!,3T]+4R!&3U(@5$A%($I34B=3($%.1"!&
M25A%4YN@ !,3 %1(12!!1$1215-315.;J@ &!@";M  H#S: +0Y!!Y0    4
M* !35$%25"!/1B!(04Y$3$52(%1!0DQ%F[X *1$'/CI&.H L+# / 44;'S: 
M+8 E#D #     !0I"@Y! 9     6R !.,3:!+48Z@"4.0 $     +"5&.H E
M#D "     "PD#D$"5@   "4.0 8     %$X 1T54($5$251/4B!0551"651%
M($%$1%)%4U.;T@!'*3:"+48Z@2PE1CJ!)0Y  0     L) Y! E8    E#D !
M     !1' $-/4%D@141)5$]2(%!55$)95$4@041$4D534YO< "04-H,M4#J"
M)PY! E8    L%"0VA"V")H,D#D$"5@   !;F $,E!H4M1CH.00=#    +"5&
M.@Y!!T0    L) Y! E8    4-Q\.0059    $@X        40S:&+0Y" E  
M   6\  J)#:'+2M&.@Y! 08    L)@Y %@     L) Y! E8    4*C: +8<6
M^@ ;%PB(+0X        9#D$' @   !0;(HD6! %500>*(@Y %0     IBB(.
M0(0     *8HB#D$""    "F*(@Y! D<    IBB(.00)2    *8HB#D$"5P  
M !M+# Y! P     450H.00)@    %@X!2S<'BB(.00)@    *8HB#D$$ P  
M "F*(@Y!! @    IBB(.0003    *8HB#D$$*    !M!# Y! P     42PH.
M00)@    %A@!2S<'BB(.001$    *8HB#D$$40   "F*(@Y!!%D    IBB(.
M002     *8HB#D$%&    !M!# Y! P     42PH.00)@    %B(!,PD?@!*)
M%!<V@"V )0Y  0     4)3:*+8HE#D !     !0I"8@4,PH.00-     %BP!
M'PD?@!*)%!<V@"V )0Y  0     4&R*+%!\BC!8V 2\9!XLB#@       "J,
M(@X        ;'S:++804)3:,+8,4+PH.00,P    %D !0A,V@2V+)0Y! E8 
M   DC!0;-HTM@2:&%# VC"U0.BN%)8TL)PY! E8    L%$(VBRV%)8TFC"0.
M00)6    %DH!3@D?@!*+%!<V@"V )0Y  0     4'1^ $HP4*S: +8 E#D !
M     !0Y-HHMBB4.0 ,     %#TBB11+-H@MB"4.0 ,     %$XD%E0!'PDV
MB"V %!,-#D$#@    !0?-HHM#@       !9> 0<'(HD6: $W(P>*(@Y! 9, 
M   IBB(.00)"    *8HB#D$"9    !LM# Y!!$     4-PH.00-@    %G(!
M+PD?B!*)%!<VB"V()0Y  0     4)3:*+8HE#D !     !0O"@Y! U     6
M? $K)3:.+48Z#D$'0P   "PE1CH.00=$    +"0.00)6    %"LH#P%]%H8!
M5A4M#D 0     !(.0 <     %"PH#Q)214Y534)%4B!)3E-404Q,1404/BT.
M0!      $@Y "      45B@/$T%4($1%0TE-04P@041$4D534R 6D $K%2T.
M0!8     $@Y $      4&2B.%"LM#@       !(.0",     %IH!%14?#D$%
M60   !(.0#0     %J0!$! VCRT_.H \ASR +!:N 08&%1:X 1\)'X@2B107
M-H@MB"4.0 $     %!LBBQ0?(HP6P@% "1^($H04%S:(+8@E#D !     !0=
M'X@2@Q0K-H@MB"4.0 $     %#DVBBV*)0Y  P     4/2*)%$ D%LP!5U<!
M,3 T+#(P,2PR+#(T,"PR,"PQ-S L,C0P+#4L,3 T+#$P-"PR,#(L,C X+#(U
M,2PQ-CDL,C4S+#,R+# L,"PQ-CDL,RPQ,S,L,3@U+#<V+#8TF]8!964!,3@U
M+#$P-"PQ,S,L,C,R+#$P-"PQ,S,L,C,Q+#$P-"PQ,#0L,3,S+#(S,RPQ-C4L
M,3,V+#$S,RPR,#,L,38U+#$S-RPQ,S,L,C T+#$V-2PR,S$L,3,S+#(R.2PQ
M-C6;X %B8@$R,S(L,3,S+#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