Reverse engineering Microsoft BASIC
Added 2024-10-31 00:19:02 +0000 UTC
This video is a bit of a continuation from my last video. At the end of the last video, I mentioned wanting to be able to print a string to the LCD using a single BASIC instruction. That required figuring out how to extract a string (or other expression). Not knowing much about the way BASIC worked under the hood, I looked at the PRINT instruction to see how it works and figured things out from there. This video walks through what I learned.
As always, let me know if you see anything that's overly confusing or wrong. And thanks as always for your continued support!
-Ben
One question; one request: Q: did MSFT Basic originally have only a char/string and a float data type where integers were stuck with the overhead thus limiting the # of digits? Request: Would love to see a video on how the expression evaluation function works. It had to capably support nesting and paren evaluation not to mention a fair amount of math vs. logic (embedding formula to evaluate to boolean for if/thens). This has always been a mystery to me. Good sleuthing thus far.
Michael Weitman
2024-11-02 04:40:53 +0000 UTC
Top notch like always! Love your videos, they are super inspiring and interesting!
HP van Braam
2024-11-02 00:40:49 +0000 UTC
Microsoft BASIC is much older than IEEE 754. (The first version of that standard wasn't published until 1985.) Before the standard was published everyone usually invented their own floating point formats.
The original version of Microsoft BASIC (for the 8080-based Altair) used a 32-bit floating point format.
One of the improvements in the 6502 version of MS BASIC is that it normally uses a 40-bit floating point format. (Although a few varieties of it used the older 32-bit floating point to reduce memory usage; that's one of the many options available when compiling Microsoft BASIC. But the most common versions such as those used by Commodore and Apple used the 40-bit format.)
tim1724
2024-11-01 21:57:34 +0000 UTC
Another fantastic video. Really interesting.
Noel Baker
2024-11-01 18:31:25 +0000 UTC
Yeah, I can't remember off hand what it was, but it was a special number that also incorporates the floating point. It's been a minute since I read up on BASIC's structures. IEEE 754 was ratified in 1985, but MS BASIC was made in the late 70s (especially the 6502 version). Can't say on the data type limit, but I'd guess it'd either error out, roll over the numbers, or lob off the higher bits. edit: I really should watch the video before I comment, haha. Hopefully Ben answers you better than I did.
Rya31
2024-11-01 11:03:27 +0000 UTC
Same for the numerical values. This is presumably not IEEE 754 floating point but something custom. How does it work and what is the supported range?
Stefan Bach
2024-10-31 12:14:23 +0000 UTC
Thanks for the video. Watching this makes me wonder what happens when you hit data type limits, say trying to use a string > 256 bytes.
Stefan Bach
2024-10-31 12:12:41 +0000 UTC
Hi Ben,
yet another nice video, just one question popped in my head during watching.
What else can be printed with PRINT and immediately numeric variables came on my mind. I suppose it will work, but I sort of miss it in your tests during the video.
Badger
2024-10-31 06:52:13 +0000 UTC
Another fine video. Thanks. I would be very interested in a video about how both fixed point and floating point work. Thanks again.
Jimmy Dansbo
2024-10-31 05:35:04 +0000 UTC
Thank you!
Joel
2024-10-31 02:28:22 +0000 UTC
Here's the direct link: https://youtu.be/mfT4T1pUGSY
Ben Eater
2024-10-31 02:27:21 +0000 UTC
If it's not too much bother, would you mind adding the youtube video URL in your post? When I tap the video from the patreon app it redirects to a barren "login to youtube to prove you're not a bot" page, preventing me from reaching the "open in youtube app" button.
Joel
2024-10-31 02:26:00 +0000 UTC
Nice one Ben! I'm following along on FPGA. Struggling with UART flow control as the devboard doesn't have HW flow control pins connected. Tried XON/XOFF but the FTDI part has too large buffers and it doesn't stop in time!
Hoping you interface the video card to the machine!
George M1GEO
2024-10-31 02:17:46 +0000 UTC
Did you ever publish the schematic of this version of the computer? I think the one on the website is missing flow control?
Josh and Colleen Byington
2024-10-31 00:43:57 +0000 UTC