Paging of stack

Chat about anything CX16 related that doesn't fit elsewhere
Michael Kaiser
Posts: 21
Joined: Fri Apr 23, 2021 2:47 pm

Paging of stack

Post by Michael Kaiser »


Has any consideration been made to making the stack ($0100 - $01FF) pageable?  Maybe zero page ($0002 - $00FF) as well?  This would greatly assist in multitasking.   

User avatar
desertfish
Posts: 1097
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Paging of stack

Post by desertfish »


The 65(c)02 cpu zero page and stack are hardwired to the first two memory pages.

I don't think you can work around that using some sort of external logic either.

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

Paging of stack

Post by Scott Robison »


You certainly *can* work around it using external logic. A normal access to zero page just has a high address byte of 0, so if one inserted some logic between the CPU address lines and the rest of the system, it could "easily" remap the value 0 to any other value, thus relocating zero page. The same could be true for the stack page.

I think they are much too far down the path, and increasing the complexity of address decoding would increase the cost of the system. So time and money are both reasons why I suspect it would not happen.

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

Paging of stack

Post by Scott Robison »


Note: The Commodore 128 had the functionality. Here is a video that talks about leveraging it (though I've not watched it).

I do remember seeing an example program on the 128 that used relocation of the stack (I think it was) to rapidly clear the 40 col screen by relocating it, pushing the accumulator 256 times, and repeating four times.





 

User avatar
desertfish
Posts: 1097
Joined: Tue Aug 25, 2020 8:27 pm
Location: Netherlands

Paging of stack

Post by desertfish »


@Scott Robison thanks! I was totally unaware of that!

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

Paging of stack

Post by Scott Robison »


Note: if you are anything like me, you'll be yelling at that video as he tries to work out the logic in real time to manage manipulating the various pages.

TomXP411
Posts: 1783
Joined: Tue May 19, 2020 8:49 pm

Paging of stack

Post by TomXP411 »


No, there will not be paging of the stack or Zero Page. Lorin has been pretty firm that the memory management is finalized, aside from the parts of VERA and the expansion ports (Which are still in flux.)

 

x16tial
Posts: 177
Joined: Sun Feb 07, 2021 8:23 pm

Paging of stack

Post by x16tial »


Here's how to run 2 processes on a Commander X16:

Buy 2 of them.  ?

 

(But seriously, 8 bit computers are kind of single task machines aren't they?)

Scott Robison
Posts: 952
Joined: Fri Mar 19, 2021 9:06 pm

Paging of stack

Post by Scott Robison »



41 minutes ago, x16tial said:




Here's how to run 2 processes on a Commander X16:



Buy 2 of them.  ?



 



(But seriously, 8 bit computers are kind of single task machines aren't they?)



They can multitask just as fast as they can do anything else (which is to say, not very fast by modern standards). You can split the stack into multiple smaller segments so that only the stack pointer has to be adjusted on a task switch, or a task switch can swap the stack & some / all of zero page. You still won't have memory protection or other features provided by modern systems, but it can be done.

Ed Minchau
Posts: 503
Joined: Sat Jul 11, 2020 3:30 pm

Paging of stack

Post by Ed Minchau »


I've seen a multitasking Unix-like OS for the Commodore 64 - GeckOS I think it was called. Each task uses its own stack starting at 013F, so at most 64 bytes get swapped in there when changing tasks.

Post Reply