3 ms·
Its really only with modern cross-compiling tool chains that "high level" languages like C or Pascal are close to competitive with writing in assembler for old
by dzdt 3y ago
Its really only with modern cross-compiling tool chains that "high level" languages like C or Pascal are close to competitive with writing in assembler for old 8-bit systems. Part of this is the machine target is so constrained. The 6502 (motivating and original target of the TRSE compiler) is particularly difficult.
While the 6502 has a machine call stack, it is only 256 bytes and does not allow any stack-pointer-relative operations. This is unsuitable for local variable storage of "stack frames" for recursive function calls.
Also the 6502 is a pure 8 bit processor (all registers and operations are single byte) except for the program counter, which is 16 bits. There are no registers usable as pointers, and limited hardware support for "indirect" operations thru a memory-stored pointer.
Projects like TRSE are quite amazing for opening up a lot more possibilities for what can be done in a higher level language but with near-assembler-level performance.
- chromoblob 3y ago> 6502 does not allow any stack-pointer-relative operations Almost not true. All you have to do is add the TSX instruction, which moves stack pointer into X register, then use absolute indexed addressing mode in which address of the memory operand is computed by adding together the absolute address specified in the instruction and the X register value. For example the instructions `TSX; LDA $0105, X` will load into A the byte in the stack which is 5 bytes up from the stack pointer. Cost for this is being unable to use the X register for something else. Addition also doesn't wrap around the stack page.