Open The-Blue-Wizard opened 7 years ago
If you want to reverse engineer and document it, that would be great. I don't know much about how it works. I believe one reason it is so cryptic is because it contains an interpreter for a language or virtual machine called IL (Intermediate Language?) and most of the BASIC interpreter is in IL. I got a version to run on the Briel Replica 1 as well as the original KIM-1.
OK. I am now reverse engineering the program. I also found the user manual for Tiny BASIC, and it proved to be of some help in my effort. Hopefully I will have something ready to upload to my GitHub account by the end of this week...or next week? Depends on how much time I got. Thanks! P.S. The version I will upload will be a bit different than what you have since I'm using ACME assembler.
News update: I just created my GitHub repo containing the latest version of tinybasic.asm. It now has a lot of comments plus meaningful labels. But it is still unfinished, with many areas needing more work. I try not to change anything except the interface part that hooks into my "BIOS" portion, so you should be able to copy mine over yours, with small alterations as needed. One disappointment I have with ACME assembler: Despite the claim that .xxx labels are local labels, the assembler seems to think they are global. Oh well...I simply add numbers to distinguish these labels apart. You are correct in assuming that it contains a virtual machine. I reformatted the "IL program area" to better show the code, though I must admit that there are some areas that remain mysterious, and I made some (partial) guesses about which part are BASIC tokens, especially the non alphabetical ones. My repo is https://github.com/The-Blue-Wizard/Tiny-BASIC. Go ahead and grab it, and improve the commenting. We can collaborate on that part. Thanks! P.S. I found the user manual, and included it because it proved to be some help in reverse engineering effort.
This sounds interesting -- I'll take a look at it as it progresses. Did you also see this manual? http://www.ittybittycomputers.com/IttyBitty/TinyBasic/DDJ1/Design.html
I found a 6502 version of Tiny Basic...it's in your repo! 😄 Anyway, I grabbed the code and modified it to assemble using ACME (not hard!), and modified it so it has both TOPMEM and BOTTOM memory range. then integrated it with my text mode screen manager (console style) plus a machine monitor derived from WozMon (of Apple I). I had to relocate the zero pages used by these programs to accommodate Tiny Basic interpreter. I originally had used $20-$3F zero pages, but I saw explicit uses of $23, etc (when modifying the code to use TOPMEM/BOTTOM boundaries), so I relocated them to $40-$5F range. But when running the interpreter, I noticed the text rendering got corrupted somehow, and I then looked more closely into the code. I don't see any $4x and $5x. I think the interpreter has an internal parameter stack located in zero page that somehow hit the memory range. But the source code is so incredibly cryptic to figure out!!! I am thinking about reverse engineering it and adding the document to that...though it would be quite some work. And I'm willing to submit the updates to your copy if you like. Let me know what you think or say about all that. Thanks in advance! P.S. Having more (meaningful) symbols would be helpful, plus more info re: internal working would be helpful in porting that interpreter to other 6502 platforms. P.S.S. I don't want to clone the entire 6502 repo just to push changes to one file...but I don't see how... ☹️