Coding a new BASIC interpreter in 2025 to replace a slow one
1–10 of 19 posts
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#2Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#3Huh? Don't you need to only change the "next-line-pointer" for the line that's right before the inserted line?
> but the NEXT changed the line, but on the next statement it would lost track and get back to the line following the NEXT. The loops also require their own stack, but including the counter variable address, a pointer to the TO expression, and a pointer to the STEP expression (5 words in total).
Mmm. IIRC, usually the compiled NEXT statement would store the pointer to the corresponding FOR statement, so you don't need an additional stack for loop depth during the execution. But you still need it (or some other sort of chaining) during the program input so whatever.
> Typing the program was difficult, as the keyboard bounced a lot. This happens when you read too fast the keyboard, so fast you can see that effectively the key contact isn't perfect.
Yeah... I've read that keyboard microcontrollers has to deal with contact bounce even today.
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#4Can you OOPize it?
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#5https://github.com/JohnBlood/awesome-basic?tab=readme-ov-fil...
It's not as popular as Python, obviously, but that lists over fifty implementations of BASIC.
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#6> I discovered the pointer to the next line wasn't a good idea, because it needed to move every pointer after a line insertion. Huh? Don't you need to only change the "next-line-pointer" for the line that's right before the inserted line? > but the NEXT changed the line, but on the next statement it would lost track and get back to the line following the NEXT. The loops also require their own stack, but including the…
I get the impression that they were storing everything sequentially in memory, rather than having a linked list of instructions. Why? I can only speculate. Perhaps it is to make memory management simpler (don't have to keep track of which addresses are in use), or to avoid memory fragmentation in system with limited memory (any modification of code would introduce unusable holes). If that's the case, what you want is an offset rather than an absolute address.
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#7Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#8> I discovered the pointer to the next line wasn't a good idea, because it needed to move every pointer after a line insertion. Huh? Don't you need to only change the "next-line-pointer" for the line that's right before the inserted line? > but the NEXT changed the line, but on the next statement it would lost track and get back to the line following the NEXT. The loops also require their own stack, but including the…
> I discovered the pointer to the next line wasn't a good idea, because it needed to move every pointer after a line insertion. I get the impression that they were storing everything sequentially in memory, rather than having a linked list of instructions. Why? I can only speculate. Perhaps it is to make memory management simpler (don't have to keep track of which addresses are in use), or to avoid memory fragmentati…
I expect that’s because that is how ‘every’ homecomputer basic did it. Yes, that makes it slow to insert or remove a line close to the start of a long program, but it allow those offsets to be 8 bits, gaining a precious byte over a 16-bit absolute address.
Now, why they initially chose to waste those bytes? I wouldn’t know, but I guess that, because (FTA) “The CP1610 processor cannot address directly the internal memory in byte terms, instead everything is handled by full word”, they didn’t think of using a single byte.
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#9I applied for a job about 12 years ago where the company was still using BASIC for some of their software. If I remember correctly it was numbered BASIC, not the more modern stuff. I think the software was doing some type of accounting—stuff that worked and they didn't want to change.
Could be one of those with the everlasting ERP type software running on an emulator.
Re: Coding a new BASIC interpreter in 2025 to replace a slow one
#10I love basic Can you OOPize it?