What I didn't say at 2:00 a.m.
This fix always inserts a colon before ELSE, even if there is already one there. It's not perfect, but the goal is to prevent a crash which is worse, and do it without slowing things down.
If there was enough space, I'd scan each line to remove redundant colons before copying them to their final location. Extra spaces could be removed as well. We could even create a new command to enable or disable the feature. Sounds great right?
Well call it CRUNCH and parameters are 1 and 0, for ON and OFF.
"CRUNCH" is 6 bytes that have to be added to the command table, and we have to store a pointer to where it is in ROM which is 2 bytes. That leaves 2 bytes of ROM which isn't even enough for the JMP instruction to return to the main interpreter.
If it's a permanent feature we save 8 bytes, but a single test and branch take 4 bytes, and I don't think it's going to fit in 10 bytes.
Give me more ROM and I can do a lot.
Back on April 1st, I said the Color BASIC version of IF THEN ELSE was about 60 bytes. I expected to possibly have 30 unused bytes left when I started, but all the special cases ate that up, and this has none of the 16 bit optimizations I wanted to add to the code. So as far as running faster goes, yes it does but not like I'd hoped.
Now I'm going to clean up the code and put padding in front of the math library so the math functions sit at their original addresses. That way anything that directly calls the math library will still work.
I think I'll call that good for the final V2.0 ROM unless I find another bug. Maybe I can fix the bug in VARPTR in 10 bytes if there aren't any bugs related to ELSE.
*edit*
The math library is already at the correct address since the text string with the programmer's name followed it, and it happens to be... 10 bytes long. How weird of a coincidence is that.
If I create a run only version that eliminates CSAVE, I could put in quite a few math optimizations. It would mean editing and testing with one version, and using another version just to RUN the final code. Both versions could be burned into a 16K ROM and an external switch could be used to switch between versions with CSAVE or fast math.
Come to think of it, the version might even be switchable at the command prompt without even rebooting the computer.
No comments:
Post a Comment