2 ms·
This is not only an excellent answer but also a fantastic history of the development of the stack. > "I've found no particular evidence that the stack pointer
by weinzierl 6y ago
This is not only an excellent answer but also a fantastic history of the development of the stack.
> "I've found no particular evidence that the stack pointer was made a full 16 because they felt any need for a stack to be that large. It's clear that at least some experienced microprocessor developers (the MOS 6502 team) felt that an 8 bit stack pointer (256 byte stack) was plenty. It's possible that the 8080 designers disagreed, or it's possible that they felt they couldn't force a particular area to be RAM, as the 6502 designers could. (Even more than the MC6800, the 6502 design strongly encouraged page $00 to be RAM, so forcing page $01 to be RAM was no hardship.) Or perhaps it just didn't occur to them that registers pointing into memory could be any less than 16 bits."
To add a little bit of detail to the preceding paragraph:
A page in 6502 parlance is a contiguous block of 256 bytes in address space. Page $00 are the first 256 bytes of address space, page $01 are bytes $0000 to $00FF and so on. Page $00 (so called zeropage) is treated specially by the processor and is therefore required to be backed by RAM (not ROM or IO).
The 6502 has an 16 bit address bus but only an 8 bit stack pointer. The stack was fixed at 256 bytes (a page) in size and fixed in location at
$0100-$01FF (page $01).
So the point made above is that because the 6502 already required the zeropage to be RAM it was easy to require the RAM for the stack in a fixed place too, while the designers of other contemporary processors didn't have that luxury.
- a1369209993 6y ago> Page $00 are the first 256 bytes of address space, page $01 are bytes $0000 to $00FF and so on. Er, you mean page $01 is bytes $0100 to $01FF, right? And 6502 in general didn't use flat addressing, IIRC; eg `12FE,x` would address 12FE,12FF,1200,1201,... with increasing x register, rather than 1300,etc.
- weinzierl 6y ago> Er, you mean page $01 is bytes $0100 to $01FF, right? Yes, yes, thanks for the correction. > And 6502 in general didn't use flat addressing, IIRC; Not so sure about that. > eg `12FE,x` would address 12FE,12FF,1200,1201,... with increasing x register, rather than 1300,etc. This is correct but I think this is more due to the fact that the index register wraps around, and I would still call it flat addressing. A better argument to not call it flat would be the use of bank switching, which I think was common in 6502 based designs. But, yeah, this is probably just splitting hairs over terminology and I agree with you. Thanks for the corrections.