4 ms·
https://github.com/mist64/cbmbasic/blob/master/runtime.c https://github.com/mist64/cbmbasic/blob/master/runtime.c: * CBMBASIC implements CHRGET/CHRGOT as s
by abiogenesis 6y ago
https://github.com/mist64/cbmbasic/blob/master/runtime.c https://github.com/mist64/cbmbasic/blob/master/runtime.c:
* CBMBASIC implements CHRGET/CHRGOT as self-modifying
* code in the zero page.
I did quite a bit of programming on the C64 but I didn't know that. I always thought that, although there is no technical reason not to, zero page is only used for storing data and not code.
- classichasclass 6y agoIt's entirely for speed reasons. It's a very hot routine and exists in RAM to facilitate speedily loading and updating the BASIC text pointer, which is embedded within it, so having it in zero page optimizes it further. Modifying this code fragment to point to your own code and add additional commands to BASIC was called a "wedge" and for some systems was the only easy way to do so. It is a central component of all 6502 Microsoft BASIC variants. See https://www.pagetable.com/?p=774 https://www.pagetable.com/?p=774 for the routine in its entirety.
- AlbertoGP 6y agoWow, I did my own BASIC extension back in the day and just now I learned from you where the name “wedge BASIC” came from. Thanks!