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

Re: Unixisms on top of P8?



pitz wrote:
> On Friday, December 21, 2012 7:36:17 PM UTC-8, mdj wrote:
>> Going all-out Unixy requires multitasking, and doing this well on the
>> 6502 is extremely difficult, primarily because of the 6502 having a
>> single 8 bit stack pointer. This means that the stack is at a fixed
>> location in memory - page $01.
>> 
> This has been one of the real weaknesses of the 6502 in relation to
> general-purpose "multi-tasking". The stack-based architecture has emerged
> as a "must" for general-purpose and modular programming.  256 bytes is
> really tight for the stack address space shared by multiple tasks.
> 
> MOS should have opted for a 16-bit stack pointer; the program counter is
> already 16-bit. 

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.

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.

That would allow two programs a 64 KB stack each. Woz could have put his
input buffer at page $3 instead.

-- 
]DF$
Apple II Book: http://macgui.com/newa2guide/
Apple II Archive: http://macgui.com/vault/
Apple II Web & Blog hosting: http://a2hq.com/