• Please review our updated Terms and Rules here

Weirdness in Microsoft BASIC 6502 source code

BobApplegate

Experienced Member
Joined
Feb 23, 2004
Messages
117
Location
Medford, NJ
Over the past few weeks I have been working a lot with the Microsoft 6502 BASIC from pagetable:

https://www.pagetable.com/?p=46

The KIM-1 version (kb9) works perfectly as-is, but as I started to expand the code, all sorts of weird things began happening and I’m wondering if anyone else has experienced similar things.

In general, I found that adding more code seems to break some integer/floating point functionality. My first change was to add about 100 bytes to the SAVE/LOAD logic and then doing a LIST would show some line numbers as floating point rather than integers. The line numbers are stored as 16 bit integers, but doing a LIST would sometimes print weird line numbers like 9.97694 rather than 10.

The other oddity is adding a new keyword broken things like interpretation of floating point numbers such as “FOR X=1 to 10 STEP .5” would always return X as the value 1.

The “source code” has been reformatted quite a few times and isn’t the original Microsoft code. Even the “original” code has comments saying it has been reformatted. The intent of the code on pagetable is to reproduce the binary image of multiple versions of 6502 BASIC, which it does nicely. However, it’s not true source and seems to have errors that only appear if changes are made.

Has anyone else looked into these problems are maybe solved some? I figured I’d ask before digging into the code more than I already have.

Bob
 
Can you tell if they use the hack of code being used as constants, so that you can't move routines to other places in memory?
 
I'm not sure where the actual problem is, but in one scenario integers are printed as floating point numbers, implying a slight change in the original value somewhere. I'm probably going to have to set breakpoints and single step through the logic to print integers and see where things fall apart. There are two main subroutines: one to convert an int to a FP number, followed by a subroutine to print a FP number. The print function has logic to recognize a non-fraction number and print is as an integer. The question is whether the int-to-FP subroutine is failing, or the print-an-FP subroutine is.

Bob
 
Back
Top