The Atari Disk Operating System (DOS) supports the use of a file named AUTORUN.5YS that has a very special characteristic. At system start-up, the DOS loads and runs this file automatically if it exists on the mounted diskette. This allows you to arrange for your Atari to come up smart.
The AUTORUN.SYS file could contain a machine language program that loads and runs. It could also contain just a short program to do some routine operations like setting the screen margins or color before passing control to BASIC. However, the major use I've seen for AUTORUN.SYS is to direct the system to load and run a BASIC program. Not only does this type of operation save you some time and effort, but it also allows an unskilled operator, like a student, to turn on the machine and interact with an application program without getting into the details of LOAD or RUN instructions.
So far, so good. Why doesn't everyone use the AUTORUN.SYS file? Apparently the major obstacle to its more widespread use is the fact that it is a machine language routine. Thus, it requires knowledge of 6502 machine language and, for complex operations, some knowledge of the intricacies of the Atari Operating System to create a functional AUTORUN.SYS file. Unless someone came up with a program to do it for you.
"Automate" (Program 1) is just such a program. If you key in this program correctly and run it, Automate will help you create your own personal AUTORUN.SYS file, and it won't hurt a bit. The program starts by asking you to input the series of commands you wish to be executed at start-up. You enter the commands exactly as you would if the machine came up in its normal ready state. The only limit on the number of commands is that the total number of characters entered may not exceed 196 (including the Atari end-of-line character added each time you hit RETURN). The program keeps track of the number of characters entered and will prevent you from exceeding this limit. After you've entered the final command in the sequence, the program will create an AUTORUN.SYS file on the mounted diskette. Note that any previous AUTORUN.5YS file will be overwritten by this operation.
The next time you boot up from the diskette bearing the AUTORUN.SYS file, the AUTORUN.SYS program will be run. This will cause the commands you entered to be executed in the order they were entered (although they will not be displayed), then control will be returned to the system. The commands, of course, must be compatible with the cartridge in use (BASIC, Assembler Editor, etc.) or an error will result. If at any time you wish to boot up from a diskette and circumvent the AUTORUN.SYS file, just hold the OPTION key down until system initialization is complete. The AUTORUN.SYS file created by Automate checks that key and, if it finds it depressed, the command list will not be executed.
To demonstrate the use of the program, a single command BASIC example will be presented. Let us suppose there exists a BASIC program entitled BEGIN which you would like to run automatically at start-up. Using Automate, you enter (as Command #) the statement:
GR.O:?"Autoboot in progress:":RUN"D:BEGIN"
then press RETURN. Assuming you entered the command correctly, you respond to the question:
Is that correct (YIN)?
by pressing Y. When the program asks if there are:
More commands (Y/N)?
respond by pressing N. The program then creates the AUTORUN.SYS file and displays READY when it's done. If you now turn off your computer and switch it on again, you will find that it "comes up" running program BEGIN. How simple can you get?
This section is for those who are not satisfied with just running the program, but are also interested in knowing how it works. Let's first take another look at Program 1. Automate consists of three major sections. The first section (lines 50 through 130) are for documentation and initialization. The program employs two key numeric variables: I, which counts the number of commands entered, and L, which counts the total number of characters in the command list. The second program section (lines 140 through 350) INPUTs the commands one at a time. As each command is entered, the program allows for error correction, checks command list size, packs the command into B$ and tacks on an ATARI end-of-line (EOL) character, namely CHR$(155). The third section of the program (lines 360 through 600) actually creates the AUTORUN.SYS file.
Before this third section is discussed, I direct your attention to Program 2. This is the assembly listing for the core of the AUTORUN.SYS program. What this machine language program does, in a nutshell, is to temporarily take over the task of supplying screen editor data by substituting a new device handler table and "get character" routine for the default ones provided by the operating system. At system start-up while the AUTORUN.SYS program is active, it intercepts all the keyboard entry requests and feeds out, one character at a time, the commands which you have entered. When it has sent out the last character of the last command in the list, it re-installs the default screen editor handler table, and the system takes over from there.
Returning to the section of the BASIC program which creates the AUTORUN.SYS file, you will find that it consists primarily of three loops. Loop one (lines 490 through 510) PUTs the core program and its associated 6-byte header into the file as READ from the DATA statements in lines 430 through 480.
Note that in line 500 of Automate, two numbers are changed from the values shown in the DATA statements before putting them into the AUTORUN.SYS file. The first is a byte in the AUTORUN.SYS file header which gives the end of the program when loaded in memory. This is the sum of the core program length and the number of bytes in the command list. Automate also alters the value of the immediate argument of the CPY instruction in line 370 of Program 2. This byte is set equal to the total number of characters (including EOLs) in the command list. Loop two (lines 530 through 550) PUTs in the command list which resides in B$. Finally, loop three (lines 580 through 590) adds a 12-byte postscript to the file, which provides the system with the initialization and run locations for the routine.
The BASIC program here provides an easy way to create a useful AUTORUN.SYS file. There are dozens of ways this file can be used. It doesn't necessarily have to be a serious application. For example, it's sort of fun just to start up my machine, listen to it go through its disk machinations, then see it automatically display the personalized greeting:
READY WHEN YOU ARE, J.W.!
50 I=0:L=0:MAX=196
60 DIM A$(MAX),B$(MAX),R$(1)
70 OPEN #1,4,0,"E:":OPEN #2,4,0,"K:"
80 ? "This program helps you to create"
90 ? " a personalized AUTORUN.SYS file"
100 ? " which, following the disk boot"
110 ? "{3 SPACES}process, automatically issues"
120 ? "{4 SPACES}a set of commands that you"
130 ? "{5 SPACES}specify."
140 I=I+1
150 ? :? "Please enter command #";I;"."
160 ? :INPUT #1;A$
170 POKE 766,1:? :? "Command #";I;":";A$:POKE 766,0
180 ? :? "Is that correct (Y/N)? ";:GET #2,X:? :R$=CHR$(X)
190 IF R$="Y" OR R$="y" THEN 220
200 IF R$="N" OR R$="n" THEN 150
210 GOTO 170
220 X=L+LEN(A$)+1-MAX
230 IF X<=0 THEN 260
240 ? :? "Command #";I;" is ";X;" character(s)"
250 ? "too long.":I=I-1:GOTO 270
260 B$(L+1)=A$:L=LEN(B$):B$(L+1)=CHR$(155):L=L+1
270 ? :? "Current command list:"
280 POKE 766,1:? :? B$:POKE 766,0
290 IF L>=MAX-1 THEN ? "Command list is full.":? :GOTO 370
300 ? "Command list can hold ";MAX-L-1;" more"
310 ? " character(s)."
320 ? :? "More commands (Y/N)? ";:GET #2,X:R$=CHR$(X)
330 IF R$="Y" OR R$="y" THEN 140
340 IF R$="N" OR R$="n" THEN 360
350 GOTO 300
360 ? CHR$(125);
370 ? "Mount diskette which is to bear"
380 ? " the AUTORUN.SYS file, then"
390 ? " press RETURN. ";:GET #2,X:CLOSE #1:CLOSE #2
400 ? CHR$(125);:? "Writing AUTORUN.SYS file."
410 OPEN #1,8,0,"D:AUTORUN.SYS"
420 REM PUT OUT THE HEADER AND THE CORE MACHINE LANGUAGE PROGRAM
430 DATA 255,255,0,6,59,6
440 DATA 173,31,208,41,4,240,10,169,18,141,33,3
450 DATA 169,6,141,34,3,96,251,243,51,246,33,6
460 DATA 163,246,51,246,60,246,76,228,243,0,238,33
470 DATA 6,172,33,6,192,0,208,10,169,0,141,33
480 DATA 3,169,228,141,34,3,185,59,6,160,1,96
490 FOR I=1 TO 66:READ X
500 IF I=5 OR I=48 THEN X=X+L
510 PUT #1,X:NEXT I
520 REM ADD THE COMMAND LIST
530 FOR I=1 TO L
540 X=ASC(B$(I,I))
550 PUT #1,X:NEXT I
560 REM APPEND INITIALIZE AND RUN VECTORS
570 DATA 226,2,227,2,0,6,224,2,225,2,17,6
580 FOR I=1 TO 12:READ X
590 PUT #1,X:NEXT I
600 CLOSE #1:? CHR$(125);:END
Listing. Automate.
Download (Saved BASIC) / Download (Listed BASIC)
D01F 0100 CONSOL = $D01F 0320 0110 DEVTAB = $0320 E400 0120 OLDDHT = $E400 0130 ; 0000 0140 *= $0600 0600 AD1FD0 0150 INIT LDA CONSOL ;Load the console switch register 0603 2904 0160 AND #$04 ;and check for the OPTION key. 0605 F00A 0170 BEQ RUN ;If it's pressed, branch to the RTS. 0607 A912 0180 LDA #NEWDHT&$00FF ;Otherwise, install the vector 0609 8D2103 0190 STA DEVTAB+1 ;to the new device handler table 060C A906 0200 LDA #NEWDHT/256 ;in the appropriate place in the 060E 8D2203 0210 STA DEVTAB+2 ;device table and 0611 60 0220 RUN RTS ;return. 0230 ; 0612 FBF3 0240 NEWDHT .WORD $F3FB ;This is the replacement 0614 33F6 0250 .WORD $F633 ;screen editor handler 0616 2106 0260 .WORD GET-1 ;vector table. All the 0618 A3F6 0270 .WORD $F6A3 ;vectors have their default 061A 33F6 0280 .WORD $F633 ;values except for the 061C 3CF6 0290 .WORD $F63C ;GET routine. which 061E 4C 0300 .BYTE $4C ;points to the replacement 061F E4F3 0310 .WORD $F3E4 ;routine below. 0320 ; 0621 00 0330 COUNTR .BYTE 0 ;character counter 0340 ; 0622 EE2106 0350 GET INC COUNTR ;Increment the character 0625 AC2106 0360 LDY COUNTR ;counter. Compare it with 0628 C000 0370 CPY #ENDLST-BEGLST ;the command list length. 062A D00A 0380 BNE CONT ;If not equal, branch to CONT. 062C A900 0390 LDA #OLDDHT&$00FF ;Otherwise, reinstate the 062E 8D2003 0400 STA DEVTAB +l ;default screen editor handler 0631 A9E4 0410 LDA #OLDDHT/256 ;table vector at the proper 0633 8D2203 0420 STA DEVTAB+2 ;spot in the device table. 0636 B93B06 0430 CONT LDA BEGLST-1,Y ;Fetch the next character 0639 A001 0440 LDY #1 ;from the command list and 063B 60 0450 RTS ;return. 0460 ; 0470 BEGLST 0480 ;The command list goes here. 063C 0490 ENDLST .END
Listing. Assembly Listing.
Download (Saved OBJect) / Download (Listed ASeMbly)
Note, the above listing is the output of the assembly process, not the actual assembly code.
Return to Table of Contents | Previous Section | Next Section