3 ms·
The writer wonders if a compiler would fit in 14K of ROM. I remember, for the Commodore 64, in some old Compute! book, a compiler called "Sprint" if my memory
by tenebrisalietum 7y ago
The writer wonders if a compiler would fit in 14K of ROM.
I remember, for the Commodore 64, in some old Compute! book, a compiler called "Sprint" if my memory is correct.
This book featured programs you could type in using their program "MLX" (which was a BASIC program you had to type in as well). "Sprint" was one of these. The program was about 6K (it definitely was the biggest program in the book).
I never typed it in. I remember it having limitations, like considering all variables integers and not supporting the DIM statement fully.
I'm not too familiar with BBC BASIC but my understanding was you could mix 6502 opcodes in with BASIC statements and basically do inline assembly. That would seem to be the optimum strategy for old 8-bit computers that would have to store the source and object code in as little as 64K or less of RAM.
----------
> A NEXT, however, must check each time the stack of FOR statements to find the variable to increment and the line to jump to.
This is why on most BASICS we always left out the variable, most BASICs would "automatically" loop to the outermost FOR.
- ta-gazette22 7y agoHere is a link to Sprint published in Compute's Gazette from January 1986 -- https://archive.org/details/1986-01-computegazette/page/n73 https://archive.org/details/1986-01-computegazette/page/n73 Integer and string only, no parentheses (strict left to right evaluation), array sizes were limited to 126 elements and one dimension, but longer variable names. Converting a normal C= 64 program to work with it was daunting. This issue also has a machine language assembler, which I did use extensively.
- ebg13 7y agoI don't know how BASIC compares to Pascal, but there was a Pascal compiler that fit. This is a really cool writeup about it. https://web.archive.org/web/20180911174601/http://www.supercoders.com.au/blog/nickgammongpascal.shtml https://web.archive.org/web/20180911174601/http://www.superc...
- Someone 7y ago”This is why on most BASICS we always left out the variable, most BASICs would "automatically" loop to the outermost FOR” Innermost (https://www.c64-wiki.com/wiki/NEXT https://www.c64-wiki.com/wiki/NEXT, https://en.wikibooks.org/wiki/Visual_Basic/Loops#Nested_Loops https://en.wikibooks.org/wiki/Visual_Basic/Loops#Nested_Loop...) Also, I don’t think that solves the fundamental problem that (edit: you can get very close. If you maintain a stack of ‘for loop contexts’, NEXT without loop variable name(s)) is little more than an indirect jump), in Basic, for loops don’t introduce a scope, making ‘innermost’ not really a thing (“most recently encountered” is a better way to phrase it) My Basic is very rusty, but I think this is valid in a classic Basic interpreter: 10 input f 20 if f = 0 goto 50 30 for i = 1 to 10 40 goto 60 50 for j = 1 to 25 60 print “foo” 70 next Whole-program analysis likely can convert most, if not all, uses of NEXT to jumps in ‘normal’ code, but fitting that in 14 kB may be problematic.