Home Page  


LAST ARCHIVE

 


ARCHIVES INDEX

 


NEXT ARCHIVE

 

Archives Index


21 January 2004

PET PRATTLE 5

Joe Griffin


 

(This article was first published in the ICPUG Journal NOV/DEC 1988 issue.
Permission from Joe Griffin to republish on the Internet has been received.)

the only replacement for an

8032 is another 8032!

Toolkits and Program Management

Are you one of those mythical programmers who develop a program on paper, fully debug it, then type it into the machine and never need to alter it?
I know that I'm not, nor is Jim Butterfield, so I doubt whether you are. In addition to bug-fixing, programs need upgrading, to take account of changes in hardware, additional features in the program and other mods. With the best will in the world, the program which started out with lines at regular intervals of 10 throughout its length, can rapidly become difficult to work on. Especially, when you discover that your impressive new feature which is 25 lines long, needs to be squeezed between lines 750 & 760.
To handle this situation you need what could be termed "Programmer's Commands". These are the extended command set which allow program maintenance. Some, though not all, of the usef ul commands have been incorporated in the BASIC 7 of the C-128..

Programmer's Commands

When the first PETs came out, the BASIC did not include any "Programmer's Commands". If you wanted to delete a range of lines, then it had to be done by tediously typing the line numbers in. Re-numbering a program consisted of listing it (a printer was a luxury item) and making a note of all GOT0s and GOSUBs, then it could be manually changed. Commands such as FIND and CHANGE were undreamed of luxuries only found on large computers.
Soon we developed little BASIC subroutines to do things like DELETE - write the line numbers down the screen, then poke a carriage return over each, to action the delete. MERGE was performed using tricks with the keyboard buffer, as shown in Alfred Minter's article last time. Rae West's book contains a host of utilities of this sort.
All this was tedious, so when Palo Alto Integrated Computer Systems (PAICS) produced a toolkit in machine code, it was greeted with considerable enthusiasm. The toolkit came as an expansion board for Original-ROM machines or as a plug-in chip for Upgrade-ROMs. The toolkit gave ten new commands, wedged into the operating system,These basic commands have in one way or another stayed the course over the years.

AUTO  _  generate automatic line numbers
DELETE  _  delete a block of lines
NUMBER  _  renumber a program, including GOT0s & GOSUBs
APPEND _  add one program to the end of another
this was not a merge, line numbers remained unchanged
DUMP  _  provide a list of all simple variables used
FIND  _ find all occurrences of a string, variable or keyword
TRACE _ show line numbers being executed, as they are used
STEP  _  single step through the program
HELP  _  display the cause of an error
OFF  _ turn the toolkit off

It is interesting to note that APPEND, not MERGE was supplied. This did not interweave the two programs and you were required to re-numbered the programs with distinct line-numbers before the append. Afterwards the program could be re-numbered to give a continuous set of line numbers.

In Canada, a software toolkit was developed by Bill Seiler, a Commodore employee. This product was called BASICAid and was at one time sold by Commodore. The machine code sat at the top of RAM, protected from BASIC by resetting the top of memory pointers. The commands were mostly the same as in the PAICS toolkit, though a true MERGE replaced APPEND, the DOS wedge was incorporated, to help disk use~s and a CHANGE command was added.

Some time later a group of ICPUG-SE members did an upgrade to BASIC-Aid, combined it with Supermon and produced a pair of chips called BASMON and PLUSDOS. These were originally only available to members who provided proof of purchase of the original CommodoreBASIC-Aid.

Commercial products included "Command-O" and Brad Templeton's "Power". The latter is the toolkit I used at work to develop a large suite of technical programs. Its two strongest features, in my opinion, were the ability to scroll forwards or backwards through a listing, much easier than listing 20 lines at a time on the screen, and a four parameter re-number. With this, it was possibie to selectively re-number a block of code in the middle of a program, without disturbing the line numbers on either side - very useful when the subroutines all begin at "sensible" numbers.

Bill Seller placed BASIC-Aid in the Public Domain, together with its source code. This was written not with the CBM assembler but with the rival MAE product. The product was enhanced for the BASIC 4 machines and added such features as bi-directional scrolling, text screen dumps and the ability to read programs and data files without disturbing any program in memory. The number of commands available had grown to 25 plus the DOS wedge. Both the source code (converted to the CBM Assembler) and various versions of the program are available in the PET library. Disk U2 contains versions for 3032, thin-4032,fat-40 and 8032, all available in versions for Commodore or ASC11printers. The disk also contains two "mini-aid" programs, which do not use much RAM but give a restricted sub-set of commands (NUMBER,DELETE, FIND & CHANGE).

For the 700 machines, there is an excellent "free-ware 'toolkit 'KEYTRIX' available from Liz Deal. The latest version l have of Keytrix is Version X1 on Liz's 1986 disk, and is a pleasure to use, with bi-directional scrolling inside windows, a four-parameter re-number and other goodies. If you have a 700 and use it for BASIC programming, I suggest you send to me for this disk.

Similar utilities exist for other Commodore machines, BASIC-Aid for the C-64, David Hook's adaptation of Tiny-Aid to the Vic and Aid128 for the C-128

Programmer's Utilities

The next stage up from the simple, but extremely useful, commands are the utility programs which can perform quite complex operations on program files.

One.very useful utility program written by Jim Butterfield is "LISTER". This program (and its successor "LIST-ALL') read a program file from disk, a byte at a time. As the program is read in,Iinks and line numbers are accounted for and the tokenised line of BASIC is expanded, just as is done by the LIST command. However, LISTER goes quite a lot further.

Control characters (those funny reverse video symbols for screen control, etc.) can be expanded into understandable words.This is particularly useful if the listing is going to a non-Commodore printer, which cannot print reverse video.

Because the program is being read from disk and the interpretation is being done by LISTER, the program being read does not need to be from the same machine as is being used to list it. As an example, the C-128 has a great many more keywords than can be found on the 3032 PET, but LIST-ALL running on the 3032 can happily translates C-128 program file which contains graphics and sprite keywords.

As I work with a variety of machines, I have carried out a number of modifications to LISTER over the years. Recently added a lot more, from LIST-ALL. My own version of LISTER uses the program load address to make an intelligent guess about the source machine - PET is $0401, C-64 is $0801, CA 28 is $1C01, 700 range is$0003 and so on. As a safety net, I do allow user over-ride of the guess. In addition to those for the normal machines, tokens are included for both LOS-96 for the 8096 and SUPERBASE programs.

As well as a choice of Commodore or Epson printers, my version also allows output to disk, in either ASCII or PETSCII.

The major problem with LISTER/LIST-ALL is that reading from disk and decoding, byte by byte, is tediously slow. I have compiled the program with PetSpeed, to give a substantial speed increase.

Another of the most useful utilities around, from the earliest days of the PET, is "COMPARE", a program from CURSOR (a tape magazine for the PET). This was written by their editor, Glen Fisher, and compared two BASIC program files. It is similar in a way to LISTER, in that it reads the program file, a byte at a time from disk, building up each line of code by expanding tokens as it goes. Differences between the two programs are reported to the screen or, optionally, to a printer. The original program was for BASIC 2 (Upgrade ROM) only. Soon after I got it, I expanded it to include the tokens of BASIC 4 and then compiled it with PetSpeed to make it work at a reasonable speed. Like LISTER

it has been extensively re-written, to include all the13-bit machines and even the Superbase, program files. The latest version works in colour on my 128

Although well commented programs with lots of spaces in the lines allow ease of reading and understanding of the program, it is well known that this slows the execution time of the program. Maximum length lines, no inter-word spaces and a total absence of REMs makes for high speed. The program "COMPACTOR (on disk U2) reads a program file and gets rid of all the unnecessary stuff, creating program lines as long as possible in the process. The original file is kept, so you can go back and amend it if required. If you do lose the original, "UNCOMPACTOR" will break the program into single statement lines (as far as possible) and will put spaces back in. Obviously, it cannot put the comments back.

It is worth pointing out that if you have a compiler then compaction of the source will not increase the speed of the final compiled program.

Another way in which the speed of a program can be increased is by defining variables at the start of the program and keeping them a few as possible (ie: re-use names whenever you can). The program"CROSS-REF" (disk U1) will provide a list of all variable names used in the program, together with the line numbers where they are used. The output from this program can be directed to the printer and then used to reduce the number of variables or pre define them at the start of the program.

The final program which I will mention here is "DISKLOGGER" (again on U1). This program gives a display or printout of the size of every file on the disk. As a first estimate, it is a very good way of gauging whether two files are different - if the sizes vary, then they must be different.

Now, for a moment, put yourself in the position I found myself in recently. At work, we have changed from PETs to IBM-PCs but for a long time many of the programs developed on the Commodores were not transferred as a) they worked, b) it would take considerable effort to translate them and c) it gave the Commodores something to do.

The situation has now changed. Manufacturing and Engineering Departments of the business are relocating to North Carolina(but, from choice, I'm not). New PCs will be obtained in the US. (Those remaining here can be used by the Sales function which will remain in the UK.) The PETs are obsolete machines, built for UK power supplies and are certainly not worth the hassle and administration of taking them. However, a good number of the programs are worth taking and rather than re-type them from listings, it is sensible to transfer them electronically. This can be done fairly easily with the equipment available but first the programs need to be sorted out, duplicates and development versions dropped, so that only the latest versions are taken. During this phase I was glad that all my programs had a version number and date at the top. Other programmers were not so methodical. At one time I was faced with a set of short programs from the Stressing Department (the authors left the company long ago) - AUTO, AUT01, AUT02, AUT03, AUT04, AUT05, AUT06, AUT07 and AUTO.DPG. All the files used the same number of blocks on a disk and no documentation could be found. The only REM line in those nine files was in AUTO, DPG. The sole comment was 'Verified 27/Feb/83 by DPG to use Dr.Walker's method".

Without utility programs like COMPARE, LISTER. and DISK LOGGER it would have been virtually impossible to sort them out. Armed with these utilities, it was possible to find the differences between the various files and eventually sort out those worth keeping.

Availability of Programs

As mentioned above certain of the programs are available on the PET Library disks U1 & U2. However, I have put together a "Special Edition" disk which contains the programs mentioned above. I must stress that PetSpeed versions are 8000 series only. For 3032 and4032 users, the BASIC source is included.

In the next article I will talk about the 8096 and 8296 machines with their extra memory.


 

 

 

 


TOP