Pet Exec Hello
Gordon Campbell Toronto, Canada
When you turn on your Pet, what do you do next? I found that there was a standard set of commands, which went along with the particular diskette being used. For example, for program development, the commands I use are:
POKE 59468, 14 (set upper and lower case) POKE 59458, 62 (this may damage YOUR machine) OPEN 1,8,15,"IO" (because DOS is first) LOAD "BASIC AID", 8 (extensions to BASIC SYS 7*4096 (invoke BASIC AID) DISK "$0" (directory) REPEAT (turn on auto-repeat keyboard)
Eventually, you get tired of issuing the same old commands over and over. So I did something about it. PET EXEC HELLO is a suite of three small programs which allow you to use a 'HELLO' file on disk.
The HELLO file consists of a set of direct commands which are executed when you 'boot' from the disk. The first file on the disk must be the SIGNON program. It prints a greeting, and invokes a machine-language program called EXEC HELLO. EXEC HELLO reads in the whole HELLO file, and feeds it to the keyboard buffer one character at a time. At the end of the commands, EXEC HELLO disengages. BUILD HELLO is a program which helps you create HELLO files.
As I said earlier, the first program on the disk must be SIGNON. Thus, after turning on the Pet, key the following:
CLR 4 spaces "*",8 Home RUN
This causes the first program on the disk to be loaded and run. Very quickly, you see the commands which were entered earlier using BUILD HELLO, appear on the screen. At the end of the HELLO file you regain control at the keyboard. (Or earlier if one of the commands disengages EXEC HELLO).
Program Details SIGNON
This tiny program uses one trick. Since a LOAD command issued by a program will cause a restart, location 13 is used as a flag that we are restarting after loading the machine-language program. This location normally contains a zero.
This program does very straightforward text entry. I chose to save the HELLO text as a program file on disk, so the text is poked into memory, and the machine-language monitor invoked to save the results. The cursor-control keys are thus all active, and characters such as double-quote and comma cannot cause any problem. The only checking done in the program is to ensure that the text is not too large for the area allocated to it in EXEC HELLO.
The first thing done in EXEC HELLO is to count the number of characters in the filename. This allows the name to be changed by POKE's without having to reassemble the program. Next the error-channel and the text file are opened. The error-channel is interrogated to make sure there is a HELLO file on the disk. If not, the message *ERROR* is printed on the screen and the program breaks into the monitor. The next file is read into memory, and both channels are closed. The part of the program which feeds characters into the keyboard buffer is hooked in to the interrupt processor, and control is returned to BASIC. The interrupt routine sees if there are any characters in the buffer, and if not, deposits one. It looks at the text being passed, and if the word LOAD appears, sets a flag. At the the USR vector is pointed at the re-connect routine in EXEC HELLO, and a SYS 0 added to the content of the keyboard buffer. At the end of the text everything is restored as it was.
EXEC HELLO tries to be transparent to the rest of the Pet, so it sits in unprotected memory. This means it could be clobbered if the commands RUN a program, and cause it to process far enough to build variables on top of EXEC HELLO. Note also the warnings in the comments at the start of the listing.
EXEC HELLO could be modified to handle just about any purpose where running a program would cause problems but direct commands will work. Several of these cases (such as dumping the contents of a tape to disk) are handled by utility programs, but with EXEC HELLO the only thing you have to do to handle a new requirement is to change the direct commands on the HELLO file.
If you wish to obtain a disk containing PET EXEC HELLO along with a number of other programs, please send $12 to the author. If you do key it in or send for a disk, please give it to all your friends.