Authors
Publication
Pub Details
Date
Pages
Here’s some good news for 32K Non-Volatile Memory owners. Now there is a way to store your Basic programs in the Dock bank on the TS2068 and be able to edit them directly without transferring them into the Home bank first. This makes writing and debugging AROS programs as easy as regular HOME bank programs.
With an empty computer, an empty 32K board plugged in, and the write protect switch set to WR, enter and run the program lines below:
10 OUT 244,240: FOR x=32768 TO 32777: READ y: POKE x,y: NEXT x: DATA 1,2,10,128,15,0,0,0,27,131
20 LET y=32778: FOR x=26710 to 27710: LET n=PEEK x: POKE y,n: LET y=y+1: NEXT x
30 POKE 33563,128: POKE 33564,13: POKE 33565,128
9997 STOP
9998 CLEAR : POKE 23750,0: OUT 244,240: POKE 23635,10: POKE 23636,128: POKE 23627,PEEK 32776: POKE 23628,PEEK 32777: RANDOMIZE 1+PEEK 23627+256*PEEK 23628: POKE 23641,PEEK 23670: POKE 23642,PEEK 23671: STOP: REM EDIT AROS
9999 CLEAR : POKE 32776,PEEK 23627: POKE 32777,PEEK 23628: POKE PEEK 23627+256*PEEK 23628,128: POKE 1+PEEK 23628+256*PEEK 23628,13: POKE 2+PEEK 23627+256*PEEK 23628,128: REM SAVE POINTER
Now set the write protect switch to PR and reset the computer by turning it off, then back on. This program, when run, transfers to the dock bank. Lines 9998 and 9999 allow you to directly edit in the dock bank.
To produce the listing, enter the command, RUN 9998. After you get the OK prompt, press enter a second time. The listing will come up on the screen. After you see the listing, set the write protect switch to WR, and you can add or edit program lines.
First, you will want to delete everything except lines 9997, 9998, and 9999 because they are no longer needed. Then try entering a few simple lines for testing purposes such as:
10 PRINT "HELLO"
20 GO TO 10
Once this is done, enter the command RUN 9999, and after you get the “OK” prompt, set your write protect switch to PR. Turn off the computer and then turn it back on to reset the machine. The computer will now run your AROS program when you type RUN and ENTER. To list and edit the AROS, enter the command:
RUN 9998
When you do, the computer will execute line 9998 and return you to the OK prompt. As before, press just ENTER a second time. The AROS listing will come on the screen. When you see the listing come up, you know it is safe to set the write protect switch to WR so that you can add or edit new program lines. You will be working directly in the DOCK Bank! After every edit session, enter RUN 9999, and immediately thereafter, before you even breathe on your computer, set the write protect switch to PR.
Before every edit session, enter RUN 9998. After the computer reports “OK”, press ENTER again to produce the listing. After the listing comes up on the screen, set the write protect switch to WR and you’re ready to edit.
When Timex engineered the TS2068, they probably never dreamed that anyone would be using RAM in the dock bank, much less editing Basic in the DOCK. Therefore, a few shortcomings in the ROM must be avoided or you run the risk of crashing the computer. I use the term “shortcomings” rather than “bugs” because we are doing something with the computer which Timex never designed into the machine. The problems involve trying to add or edit any program line which contains the SAVE, LOAD, VERIFY, or MERGE commands, and stem from the way the computer checks the syntax of a line.
This in itself, could be the subject of a lengthy article, but briefly what happens is this: When you try to enter a program line, either a new one or an old one which you have changed, the computer actually begins to run the line as if it were a direct command without a line number. It does this to see if an error will be generated. If it finds something in the line which is incorrect, the machine refuses to put the line in the program. Instead, it prints the line once again at the bottom of the screen and sticks a flashing question mark (syntax error) at the point where if found the mistake. The flashing question mark tells you how far it got in parsing out the line. The problem with SAVE, LOAD, VERIFY, and MERGE, is that the computer ALWAYS assumes that these tape commands will work on bytes in the HOME bank. But we are running in the DOCK bank! When the computer tries to run the line to check its syntax, it enables the HOME bank and does not turn the DOCK bank back on when it is finished checking the line for errors. Therefore, regardless of whether the line is syntactically correct or not, the computer literally locks you out of the dock bank where you should be. Instead, you are stuck in the Home bank with a whole bunch of garbage on the screen and no way to get back. The lesson is:
NEVER, NEVER, NEVER try to add or edit a program line which contains a tape command when you are editing directly in the DOCK bank unless, of course, you want to commit suicide on your program. Fortunately, ALL other basic commands work.
Ok, I can hear you grumbling, “What good is it if I can’t save or load from an AROS program?” The answer is there’s nothing which prevents you from saving or loading from AROS. The restriction is that you can’t enter a program line which says SAVE, LOAD, etc. There is a sneaky way around the problem albeit somewhat cumbersome. What we must do is enter a different command that WILL pass through the syntax check, and then Poke the tape command in manually.
Suppose you want to enter the program line:
125 LOAD "PROGRAM"
Because the system will crash if we try entering this, replace it with
125 PRINT "PROGRAM"
As you can see, the two lines are almost identical; the only difference being the substitution of the PRINT token for LOAD. It is possible to write a short Basic program which can peek into the NVM so we can find line 125. Once we have the address of the PRINT token, we can simply POKE it with the code for the SAVE token. Before you try the following listing, enter the command RUN 9999 and then set the write protect switch to PR. Remember, it is absolutely essential that you do this EVERY time you finish an AROS editing session. Once its done, reset the computer, and POKE 23750,0 to turn OFF the AROS thereby allowing you to write this program in the home bank:
1 OUT 244,240
10 FOR X=32778 TO 65535
20 PRINT X;"=";PEEK X;TAB 12;
30 IF PEEK X>=32 THEN PRINT CHR$ PEEK X;NEXT X
40 PRINT : NEXT X
If you run this program, the screen will fill with something like that which appears below. It shows the bytes of memory in the dock bank along with the peek values and character codes. Do you see the Basic program? The first two bytes represent the first program line (line 125). The next two are the length of the line (11 bytes long). The next 10 bytes are the text of the line (PRINT “PROGRAM”), and address 32792 shows the code 13 which is the carriage return at the end of the line.
32778=0
32779=125 )
32780=11
32781=0
32782=245 PRINT
32783=34 "
32784=80 P
32785=82 R
32786=79 O
32787=71 G
32788=92 R
32789=65 O
32790=77 M
32791=34 "
32792=13
32793=39 '
32794=13
32795=2
32796=0
32797=226 STOP
32798=13
Note the PRINT token at address 32782. This is the byte that needs to be changed to say SAVE. To do this, set the write protect switch on the NVM to WR and look up the code for SAVE on page 245 of the 2068 owner’s manual. You’ll find there, that the decimal code for SAVE is 248, so just POKE 32782,248. Then write protect the memory board again.
The next time you go into the dock edit mode (using RUN 9998), you will find that the old line which said PRINT “PROGRAM” now says SAVE “PROGRAM” and if you run this line as an AROS program, the contents of the home bank will be saved to tape.
In this example, I conveniently placed the line which needed to be poked right at the start. In YOUR program, the save command may be located somewhere else and you will have to hunt for the line to find the right address to poke.
Conclusion and Summary
This article just scratches the surface of the very deep subject of using the 32K Non-Volatile memory. I will be writing much more about it as I learn its intricacies myself. This article does help a lot in making the programming process easier, but using lines 9998 and 9999 can be confusing. With lots of practice, you’ll become quite adept. Now, here is a summary of the purpose of lines 9998 and 9999 along with some Do’s and Don’ts.
After you have put lines 9998 and 9999 in the NVM, you can list and edit the AROS Basic by entering RUN 9998. Execute this command with the write protect switch set to PR. Only after you actually see the listing on the screen is it safe to move it to the WR mode.
Think of the RUN 9998 command as opening the door to your AROS program. You can’t look inside until you have opened this door.
Once its open you can add new program lines, delete, or alter existing ones. But any time you decide to turn off the computer, stop, or take a short break, you must close the door to the AROS. This is done by executing the command RUN 9999 and then, immediately after, switching the write protect switch to PR. If you do not RUN 9999, all your work will be lost!
Do not try to run the program you’re working on if you have opened the door to edit the AROS. Results are unpredictable. Instead, run 9999 first. Write protect the memory, reset the computer, and type RUN to run it as an AROS program. The only line which is safe to run while editing AROS Basic is line 9999 which closes the door.
Do not try to edit or add any program line which contains one of the tape commands (SAVE, LOAD, VERIFY, MERGE). The computer will crash if you do. Instead, insert one of these “killer tokens” indirectly by writing the line using some other token, and then substituting it with SAVE, LOAD, etc. by peeking into the Basic, and poking in the substitute at the appropriate address.
Remain constantly aware of which way you have the write protect switch set. This is good practice any time you use the NVM, but especially so when you edit an AROS program. If you’re not writing to dock memory, keep the board protected to avoid accidents.