This book points out the stack register as being 9 bits: http://www.1000bit.it/support/manuali/c ... e_code.pdf
It this true or is it a typo? Is there a way to extend the stack operation to being 512 bytes?
Stack register 9 bits?
Moderator: Moderators
Re: Stack register 9 bits?
typo
I'm just a Software Guy who has no Idea how the Hardware works. Don't listen to me.
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Stack register 9 bits?
I frankly don't know what could be misunderstood in the diagram on page 15. It shows the stack pointer as 9-bit value, with its bit 8 (value: 256) fixed at 1. It evidently follows, that the stack is located in addresses 256..511.
One could extend the representation with the higher bits 9..15 fixed at 0, and it would still be correct.
One could extend the representation with the higher bits 9..15 fixed at 0, and it would still be correct.
Re: Stack register 9 bits?
I've seen other books describe the stack pointer as a 16-bit register with a hard-wired page of one.
However you choose to represent it you can't move the stack from page 1. Shame as the push/pull instructions would be quite useful if they could access the full address space.
However you choose to represent it you can't move the stack from page 1. Shame as the push/pull instructions would be quite useful if they could access the full address space.
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Stack register 9 bits?
That begs the question why stop here, and not extend accumulator and index-registers to 16-bit as well.srowe wrote:[...] the push/pull instructions would be quite useful if they could access the full address space.
In that case you'd end up with the 65C816 or 6809.
For most applications on the 65xx, a 256 byte stack for sub-routine calls and small chunks of saved registers is probably sufficient. If a program has higher demands on stack size, it can always construct one by itself using a dedicated 16-bit pointer in the zeropage. That's what Commodore did, for example, with the 512 byte "run-time" stack on the later 8-bit BASICs, which separated FOR and DO loops, and GOSUBs from the machine-level sub-routine calls and register saves. It also helped with the handling of run-time errors, so BASIC flow-control constructions could be held alive during TRAP calls.
Re: Stack register 9 bits?
I understand that its hardwired in the Vic-20, but is it really 9 bits inside the 6502 or 8-bits. In the latter case would it be possible to hack its location by rewiring inside the machine? Since CBM didn't do it I guess the answer is obvious..Mike wrote:I frankly don't know what could be misunderstood in the diagram on page 15. It shows the stack pointer as 9-bit value, with its bit 8 (value: 256) fixed at 1. It evidently follows, that the stack is located in addresses 256..511.
One could extend the representation with the higher bits 9..15 fixed at 0, and it would still be correct.
- Mike
- Herr VC
- Posts: 4816
- Joined: Wed Dec 01, 2004 1:57 pm
- Location: Munich, Germany
- Occupation: electrical engineer
Re: Stack register 9 bits?
... when the 6502 accesses the stack during interrupt processing or BRK (push PC, push status register), with RTI, PHx, PLx, JSR, RTS, it always puts $01 as high byte on the address bus and nothing can be done to persuade it to do something else.
You could put external hardware on the address bus to snoop for addresses in the $01xx range and then exchange the high byte with another value. That's what Commodore actually provided with the zero-page and stack translation registers in the MMU of the C128. However, there was no provision to check that really only a zero-page or stack access had taken place, and so the translation would also happen with $00xx or $01xx as effective addresses of all other 'generic' accesses.
You could put external hardware on the address bus to snoop for addresses in the $01xx range and then exchange the high byte with another value. That's what Commodore actually provided with the zero-page and stack translation registers in the MMU of the C128. However, there was no provision to check that really only a zero-page or stack access had taken place, and so the translation would also happen with $00xx or $01xx as effective addresses of all other 'generic' accesses.