4 ms·
The original Turbo Pascal was a pretty simple one-pass recursive-descent compiler: https://www.pcengines.ch/tp3.htm https://www.pcengines.ch/tp3.htm It looks l
by sehugg 7y ago
The original Turbo Pascal was a pretty simple one-pass recursive-descent compiler: https://www.pcengines.ch/tp3.htm https://www.pcengines.ch/tp3.htm
It looks like this one has a lot of constraints for easy 6502 code generation, like only allowing 8-bit variables in a FOR loop.
- vidarh 7y agoCompiling most languages for 6502 boils down to either adding lots of constraints, or conceding the compiled code will end up being awfully slow. E.g. allowing 16 bit types => slow in most cases; passing things on the stack => slow or horribly restricted (because the hardware stack is tiny, so you end up emulating one at high cost if you want to be able to have more than 256 bytes on the stack). The problem is you really wouldn't write code for these machines the same way you write code for a bigger machine. Not least because most of them had so little memory that keeping track of an assembly program that size was not really a big deal. A lot of C64 demos were written in machine code monitors with no labels, no macros, no variable declarations, that just assembled/disassembled line by line, and saved by just saving the memory regions to disk - no separate source-code. It was a revelation to get a proper assembler... But that meant self-modifying code (often seen used for 16 bit loops...) and effectively global variables all over the place (= data in fixed memory locations...) was extremely common as well. Trying to shoehorn that into a language like Pascal means basically writing everything in the main block and not call any functions, and even then you're unable to use most of the dirtier tricks..