From: Olaf Seibert (
Date: 1998-09-30 00:09:03

Stephen Judd <> wrote:
> Shift-L is character code $CC -- 204 decimal, as Ethan says above.  In 
> BASIC, tokens are indicated by having the high bit set.  The highest token
> is "go" (so that "go to" works), which has token value $CB.  Although
> you might be thinking "ah, larger than the largest token", note that
> shift-M shift-N etc. list just fine; the problem only occurs with
> shift-L, and the reason is quite interesting.

Note that on Basic 1 and 4, the listing problem occurs also with the
last token + 1, and those tables have different sizes, not precisely 255
bytes. On basic 4.0, $DB does the trick, on basic 1, $CB would do it.

> Keywords are printed by searching forwards through the keyword table:
> :LOOP1   DEX              ;Traverse the keyword table
> :LOOP2   INY              ;read a keyword
> 	 BPL :LOOP2
> 	 BMI :LOOP1
> :PLOOP   INY              ;Print out the keyword
> 	 BMI LISTENT1     ;Exit if on last char
> 	 JSR HAB47        ;Print char, AND #$FF
> The last char of each keyword has the high bit set; the above code
> just counts .X characters that have the high bit set.  Note that
> absolute addressing is used, though, so that the size of the text
> in RESLST can't be larger than 256 bytes total.  
> It turns out that there are 255 text bytes in the table -- token
> $CC begins at RESLST+255, the last byte of the table, which has
> a value of zero.  So what happens is that $AB47, which prints the
> character in .A, is called with .A=0.  AB47 is part of the PRINT
> command used with the CMD command.  And what _it_ does is call
> $E10C, which calls $FFD2 and branches to an error if the carry is
> set.  But send a zero to $FFD2 and he sets the carry flag on exit, 
> causing $E10C to branch to the error routine.

Would not the above BNE :PLOOP fail after printing a 0, so that it
falls through to the code for FOR? FFD2 usually clears the carry; off
the top of my head there would be no reason why it would be set for
printing a 00 byte.

> -Steve
___ Olaf 'Rhialto' Seibert  rhialto(at)   "I would be dead in
\X/ a week if I didn't do /something/. I'd be splattered all over the walls."
This message was sent through the cbm-hackers mailing list.
To unsubscribe: echo unsubscribe | mail

Archive generated by hypermail 2.1.1.