[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 6502 Multitasking OS announce
ralph.mason@liffe.com (Ralph Mason) wrote:
>Michael Ellis <michael@anest4.anest.ufl.edu> wrote:
>
>>holger@deep.hb.provi.de (Holger Bruns) wrote:
>
>>>An operating system for the 6502 should have some of the
>>>properties of CPM. Parameters could be passed into registers
>>>and some zeropage locations.
..
>> The way to get around this is to pass all parameters on the
>> stack, and use separate stacks for the separate tasks.
>All well & good BUT the 6502 does not have a relocatable stack pointer
>so your kinda left with a bit of a problem when it commes to
>multitasking, ie you cant give each process it's own stack without
>copying the whole stack ( maybe just to the current sp value? )during
>each context switch.
Here's one way around the problem: it depends on assuming
that the standard stack entry is a 16 bit word, and that the size
of each individual stack times the number of stacks is less than 256
entries. Then the high byte and the low byte of each stack entry can
be maintained in dedicated stack pages (anywhere in the memory space,
but not relocatable for this specific approach), and accessed via
absolute X-indexed address, as in:
lda STLO,x
sta W
lda STHI,x
sta W+1
...
Advantages: A single register is used for stack reference, so context
switch overhead is reduced; reference uses a 4-clock rather than a 5 or 6
clock address mode, so it's a little bit faster, and reference works in
such a way that Y is free to be used as an auxilliary register to index
from the top of stack: and the split stack pages implies that only two
increments are required to index by 2 16-bit words. Assuming the stack
grows down, to reach the third entry, simply
txa
tay
iny
iny
lda STLO,y
sta ADR1
lda STHI,y
sta ADR1+1
...
Disadvantages: while the 256 byte hardware stack has been expanded, a
hard limit remains.
The other approach is to dedicate a pair of bytes in the 0-page to a
vector, in which case, if you rely on y-indexed addressing, you have
slightly slower access, but to index up into the stack frame you can
simply load the value; and the location can be anywhere the memory
management routines can find for it.
Virtually,
Bruce R. McFarling, Newcastle, NSW
ecbm@cc.newcastle.edu.au