Close

Bug fix

A project log for One kilobyte Tiny BASIC for the 8080 and Z80

BASIC for the 8080 and Z80, fits in 1K of memory, runs BASIC games on a 2K system. Features similar to Palo Alto Tiny BASIC.

willstevenswill.stevens 01/28/2024 at 09:200 Comments

I noticed that the @ variable name wasn’t displaying correctly (it was showing as M). This was because the ‘end of TokenList’ marker wasn’t being found. This is a byte with value FFh immediately following the list of tokens. If this byte is encountered when looking up a token, it means that the token can’t be found, and during LIST this means that it must be a variable name token because all other possibilities (line number, integer, string, end of program marker) have already been checked.

But the FFh marker is only recognised if it is 2 bytes after the last byte of the last token. I had it one byte before this. Because there is an FFh a few bytes further on, the error only affected @. There is a sequence 00 CD before FFh is encountered - 00 is the token value for @ and CDh=‘M’ or 80h, which is why it was displayed as M.

The problem was fixed by adding a second FFh at the end of TokenList, then deleting one of the two free bytes at address 014Dh (because it is important that TokenList ends at address 0222h). I hope to find a better fix that doesn’t cost a byte. I also noticed there is a potential 1-byte saving in between List_Token_Loop and List_Token_String_Loop.

Discussions