Classic Computer Magazine Archive COMPUTE! ISSUE 19 / DECEMBER 1981 / PAGE 10

"Some of your readers may be interested to know about a 'bug' in a Pet/CBM program called "BASIC AID". Suppose we have this very simple program:

1 GOTO 2

If we use the machine language monitor to examine the content of memory beginning at $0401 we will find that the line is as in (a) below. The 04 08 is the link to the next line, the 01 00 is the line number, 89 is the keyword for GOTO, 32 is ASCII 2 and $00 indicates the end of the line.

If we invoke BASIC AID and (re)NUMBER 1, 1 and re-examine memory we will find the program looks like line (b) below. Notice that we have picked up a garbage byte after the ASCII 2. If we NUMBER 1, 1 again we will find the program content is as in line (c). Note that we have picked up an additional garbage byte. Each time the NUMBER routine is invoked a new garbage byte will be added.

(a) 04 08 01 00 89 32 00
(b) 04 09 01 00 89 32 02 00
(c) 04 0A 01 00 89 32 32 02 02 00

Consider the following program line:

3 ON X GOTO 4, 5, 6, 7

The first time the NUMBER routine is used on this program line each of the four line numbers will pick up a garbage byte. However, the second time the NUMBER routine is invoked only the first line number will pick up an additional garbage byte and subsequent line numbers will be left as is.

As a result of this problem the NUMBER routine cannot reliably be used in the BASIC AID program. In particular I have discovered that the "ON-GOTO" statement will tend to bomb in long programs after use of the (re)NUMBER routine." Hal W. Hardenbergh