Classic Computer Magazine Archive COMPUTE! ISSUE 74 / JULY 1986 / PAGE 10

Readers Feedback

The Editors and Readers of COMPUTE!

If you have any questions, comments, or suggestions you would like to see addressed in this column, write to "Readers' Feedback," COMPUTE!, P.O. Box 5406, Greensboro, NC 27403. Due to the volume of mail we receive, we regret that we cannot provide personal answers to technical questions.

Atari BASIC Bugs

I have a very serious problem with my 16K Atari 600XL. Sometimes right after I've entered a line, the computer locks up and the only key that will work is SYSTEM RESET. But after I press RESET and enter another line, the computer locks up again.

Tak Lee

You're experiencing the latest incarnation of the infamous Atari BASIC lockup bug. This bug afflicts two versions of Atari BASIC: the original version, known as revision A, which was supplied as a cartridge for the 400, 800, and I200XL; and revision B, which is built into the 600XL and 800XL computers. The lockup bug takes a slightly different form in these two versions of BASIC. In revision A, BASIC is unable to delete (move downward in memory) a block of memory whose size is an exact multiple of 256 bytes. Most users encounter the bug in the form of a keyboard lockup after deleting program lines, but it can affect the movement of strings . as well. To illustrate, type in the following program:

A0 10 DIM A$(256),B$(256)
FD 20 FOR A=1 TO 256:A$(A,A)="B":NEXT A
GL 30 B$=A$
ID 40 PRINT A$:PRINT B$

This creates a string variable, A$, that consists of 256 B characters. Then it makes B$ equal to A$. When the program runs, you would expect it to print the letter B 512 times. Type RUN to see what happens instead. If you have revision A BASIC, the first 256 characters are correct but the remaining characters are garbage. This occurs because BASIC's memory move routine was unable to move the value of A$ into B$ correctly. To confirm that the bug applies only to blocks of memory in multiples of 256, try changing the number 256 in lines 10 and 20 to some other value.

This bug was corrected when revision B BASIC was prepared for the 600XL and 800XL. However, Atari's programmers got carried away and applied the same correction to a routine which didn't need fixingÄthe routine which inserts (moves upward) blocks of memory, which happens when you add a BASIC program line. As a result, revision B BASIC has its own lockup bug which rears its ugly head when program lines are inserted instead of deleted. Ironically, the revision B bug may occur even more often than the old one--you add program lines more often than you delete them. As an example, turn your 600XL or 800XL off and back on, then enter the following line in direct mode:

DIM A$(249):A$="TRASH"

Enter PRINT A$ to see the variable value. Now enter this program line:

10 PRINT "THIS IS A TEST"

Before doing anything else, try to print the string again:

PRINT A$

If you have revision B, your computer should be locked up, and pressing RESET won't recover. For more details, see Bill Wilkinson's "Insight: Atari" columns in the May and June 1985 issues of COMPUTE!

The line-editing bug is not the only problem in early versions of Atari BASIC. Here's a list of some of the other bugs in revision A:

  1. Because the value -0 is interpreted incorrectly, printing -0 yields garbage.
  2. There's a problem with the precedence of the NOT operator which causes it to give unpredictable results in some cases. Type the following statement in direct mode when you have no other program in memory: PRINT NOT NOT 1.
  3. LOCATE and GET statements may corrupt the internal buffer pointer. This can cause difficulties when trying to READ from DATA statements or when using the VAL function. If you have trouble with READ or VAL, use the statement X$=STR$(0) to reset the buffer pointer after a GET or LOCATE.

Revision B BASIC corrects some of the bugs from revision A, but also adds a few of its own. Here are some revision B bugs.

  1. BASIC adds 16 bytes to the end of a program every time you LOAD or CLOAD it. After loading and saving the same program several times, you'll find that it has grown substantially. To remove the extra bytes, LIST the program to disk or tape and ENTER it back into memory. To avoid the problem, always use LIST/ ENTER instead of SAVE/LOAD.
  2. CLOAD and CSAVE commands fail to turn off the sound after they're done. Use END or the statement SOUND 0,0,0,0 to silence it.
  3. Occasionally, an ERROR 9 (array or string DIM error) wrongly occurs in a program line that contains a DIM statement. You may be able to fix this condition by LISTing the program to disk and ENTERing it again.

One solution is to get the newest Atari BASIC cartridge, revision C, from Atari Corp., Customer Product Service, P.O. Box 61657, Sunnyvale, CA 94088. It costs $15. This is the same BASIC built into the Atari 65XE and 130XE models.