Re:Turbo Rascal Syntax Error
by chromoblob on Monday May 08, 2023 @07:46AM
(#35860500)
> 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.
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.