network adapter / c compiler

If you have feature requests, this is the place to post them. Please note your idea may already be something we have already discussed and decided against, or something we are working on privately, and we cannot be held responsible for any similarities in such instance. Whilst we cannot respond to every suggestion, your idea will be read and responded to where possible. Thank you for your input!
mgkaiser
Posts: 34
Joined: Sat Dec 02, 2023 6:49 pm

Re: network adapter / c compiler

Post by mgkaiser »

andmarti1424 wrote: Thu Apr 13, 2023 9:40 pm I am not an expert on this topic but have you take a look at this:

http://www.6502.org/users/andre/osa/oa1.html

?
The example you show splits the stack into 16 stacks of 16 bytes each. Very limiting.

Because you only have a 256 byte stack and cannot relocate it, multitasking is very hard on a 6502. You either need to split the stack which limits number of tasks and limits task size or you need to copy the stack on context switches which is slow.

There is a project which does preemptive multitasking on a C128 but only because the C128 MMU can relocate the stack anywhere in the memory map.
tim1724
Posts: 4
Joined: Thu Jun 22, 2023 5:50 pm

Re: network adapter / c compiler

Post by tim1724 »

mgkaiser wrote: Thu Dec 07, 2023 5:18 am Because you only have a 256 byte stack and cannot relocate it, multitasking is very hard on a 6502. You either need to split the stack which limits number of tasks and limits task size or you need to copy the stack on context switches which is slow.
One of the best changes on the 65C816 was making the stack pointer 16-bit. This allowed the Apple IIGS to give each running program its own stack.

With the 65C02 I don't see multitasking as very practical, although I suppose the X16 is clocked at a high enough speed to make copying the stack on context switches not too horrible.
BruceRMcF
Posts: 222
Joined: Sat Jan 07, 2023 10:33 pm

Re: network adapter / c compiler

Post by BruceRMcF »

tim1724 wrote: Tue Dec 12, 2023 2:44 am
mgkaiser wrote: Thu Dec 07, 2023 5:18 am Because you only have a 256 byte stack and cannot relocate it, multitasking is very hard on a 6502. You either need to split the stack which limits number of tasks and limits task size or you need to copy the stack on context switches which is slow.
One of the best changes on the 65C816 was making the stack pointer 16-bit. This allowed the Apple IIGS to give each running program its own stack.

With the 65C02 I don't see multitasking as very practical, although I suppose the X16 is clocked at a high enough speed to make copying the stack on context switches not too horrible.
It does depend on what kind of muti-tasking you are doing. For example, if you have two threads of cooperative tasks plus a watchdog, 120 bytes is ample stack for each cooperative task round robin thread and 16 ample for the watchdog. Also, whatever hardware stack space you allocate to a task in a pre-emptive multi-tasking system, the tasks are not required to use the $0100 page S index stack as a data stack ... you can use addr,X indexed stacks, and of course that can be located in the HighRAM window if you wish, which gives flexibility for a number of tasks with parsimonious use of the S indexed stack.
mgkaiser
Posts: 34
Joined: Sat Dec 02, 2023 6:49 pm

Re: network adapter / c compiler

Post by mgkaiser »

Agreed and I nearly always use a software stack for parameters. But you have no choice on the call stack. JSR is going to push its return onto the processor stack. So are interrupts..

I'm actually working on cooperative multitasking, which doesn't really care about the stack. This is really just a framework to hook multiple dynamically loaded modules into a common state machine.
Post Reply