[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Unixisms on top of P8?



On Tuesday, 25 December 2012 10:04:13 UTC+10, D Finnigan  wrote:

> A 16-bit SP on a processor with only a 16-bit address space? My dear fellow,
> 
> you must live life on the edge! Imagine the havoc that a run-away program
> 
> could wreak, if it got into an infinite loop of PHAs or PHPs or JSRs.

Actually, the 6502 is the odd one out - the other popular 8 bit processors had 16 bit stack pointers.

I've never been particularly bothered by the size though, only by where it has to be placed. The auxiliary memory protocol of the IIe does solve the problem however, with the caveat that you now require extended memory. 

> Yes, it's bad on both a 256 byte stack and on a 64 kb stack, but at least
> 
> the former prevents any collision with program code and data.
> 
> 
> 
> I think a better design would have been to make use of the unused bit in the
> 
> processor status register to store stack page number. A zero bit means page
> 
> $01, and set bit means page $02. A single instruction, or a pair, would flip
> 
> this bit.

The 65816 solves the problem the right way with the direct page register. Unfortunately the high order byte of the stack pointer can't be used as a stack page register in emulation mode, but running in native mode provides ostensibly the same functionality.

Matt