Re: [cc65] Zero page, C stack, and interrupts

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2010-04-25 19:47:07
On Sun, Apr 25, 2010 at 09:12:26AM -0700, Steve Davison wrote:
> Maybe I'm missing something big then...  My project is something
> like a mini OS.  I know I'll eventually want the core of it to
> be assembly, but for now I want to see how much mileage I can
> get at a higher level.
>
> At this point, all the action happens in the interrupt, where
> the context- and focus-switching takes place.

Ok, so this is sort of special. If what you want is preemptive multitasking,
things become rather difficult. You will have to save all zero page locations
used by a program when switching the context. You will either have to split up
the stack, or save the stack, too. You will have to make sure that critical
kernal functions aren't called twice, since the kernal it is not reentrant,
not even when saving the zero page (think of IEEE operations).

If you go for cooperative multitasking, things are easier, but you still need
to save zero page locations used by a program and setting up separate stacks.

> Actually, I have no clue what the standard placement is.  If the
> linker takes care not to re-use any important locations, I'll
> have no problem adjusting to that.  =)

Placement is done by the linker and controlled via the linker config file. The
standard linker config for the C64 says:

    ZP: define = yes, start = $0002, size = $001A;

Most platforms use either free zero page locations, or locations used by
BASIC, because BASIC is not active when the cc65 compiled program runs. In the
latter case, the zeropage space is saved and restored by the startup/exit
code.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sun Apr 25 19:47:17 2010

This archive was generated by hypermail 2.1.8 : 2010-04-25 19:47:19 CEST