Bob’s Notebook: Convert Numbers to VAL$

See all articles from Sinc-Link v4 n3
Author(s): Bob Mitchell
Publication: Sinc-Link
Pub Details: Sinc-Link v4 n3 (Volume 4, Issue 3)
Date: May/June 1986
Pages: 7

Here is a short machine code program that very quickly converts all the numbers in a program to VAL expressions thereby saving quite a few bytes. I have found it very useful when trying to make room in a long program to add one of the LDOS routines used in the Larken Disk Drive system.

Type it in, run it and use it by the command RANDOMIZE USR 63100.

   1 REM COMPACTOR
5 REM run and use RANDOMIZE USR 63100
10 FOR i=63100 TO 63221: READ a: POKE i,a: NEXT i
100 DATA 42,83,92,43,237,75,75,92,35,167,237,66,9,200,35,35,78,35,70,229,35,126,254,13,32,3,209,24,231,254
110 DATA 14,32,243,209,213,11,11,11,197,120,18,27,121,18,229,43,126,254,47,40,19,254,46,56,15,254,196,40,4,254
120 DATA 58,48,7,35,35,119,43,43,24,231,35,54,176,35,54,34,225,35,35,54,34,35,84,93,213,35,35,35,229,42
130 DATA 89,92,167,237,82,68,77,225,237,176,42,75,92,43,43,43,34,75,92,42,89,92,43,43,43,34,89,92,225,193,24,155,0,0,0
199 STOP
200 SAVE "COMPACTOR": VERIFY ""

Speaking of LDOS, here are a few tips to the growing number of Larken users.

REMDOS may be used by saving it first on tape, then MERGEing it with another program (using the MERGE command on the TS2068). Be sure that Lines 1 and 2 are free for the REMDOS program.

Then call it using RANDOMIZE USR 26720. This is most useful when you are trying to save one of your programs to disk that has some code or data residing above 61000. If space is tight, it is here that COMPACTOR may come in handy, freeing up the necessary bytes.

Disk Menus.

When I build a menu for each of my disks, I try to add a routine in each of the programs on that disk that will automatically return to the menu for another selection; eg, if the program has a ‘Quit’ option that results in a STOP action, then replace that line with something like this:

CLS: OUT 84,64: RANDOMIZE USR 63488: REM load "menu.B1"

This is fairly easy to accomplish in BASIC but not so easy in machine language. So far I have been able to return only the LDOS keyboard input routine from within assembly language code. Larry Kenny talks about the DOS checking the value in address 23622 and if it is 255 then the action is as described above. Perhaps someone will know the solution to this one.

Cameron Hayne‘s Basic Compiler.

So far, it has performed very well. I have saved it to disk leaving out the logo which is frustrating on tape. I have put two games into machine code with excellent results. Others include a routine to relocate m/c to another start address and several calculating routines which move along very quickly. So it seems that Cameron has come up with a first rate utility program. Congrats to him!

Saving arrays to Disk.

Be sure to use one of the RAM versions of LDOS when you are trying to save and load arrays. With the Eprom DOS, arrays must be located first in the variables area and if they move to a different location when redimensioned during running, they cannot be located. The other LDOS’s will find the arrays no matter where they are. Also, the other LDOS’s allow the use of variable names to identify the text being saved. Saving an array t$ with a name n$ previously defined as ‘tips’ would require a line: LET n$=”t$”+n$+”.Ax” then a line, say: RANDOMIZE USR 26720:REM save n$.

Bob Mitchell June 1986.

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