Re: [cc65]zero page

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-01-06 17:00:31


On Sat, Jan 06, 2001 at 04:42:45PM +0100, MagerValp wrote:
> UvB> The runtime and C libraries use 24 zero page locations. 6 are
> UvB> used by the C code directly, another 12 are used by the runtime
> UvB> and C library for pointers and other stuff, and 6 are reserved
> UvB> for register variables (currently not available but used in the
> UvB> library here and there).
>
> So, which ones are free for us that want to mix asm with C?

If your assembler code does not call any library routines itself, you may
freely use ptr1-4 and tmp1-4 (12 bytes total), plus the sreg variable with
some precautions (it contains the high word for long values). The routines
most likely used by your code, namely popa, popax and all incspxx functions do
not use any of these zero page locations, so you may use these routines to
retrieve parameters from the stack. 12-14 bytes should be enough for most
purposes. But beware: if you are calling other library routines, the contents
of these zero page locations may get destroyed!

If this is not enough, you may use the 6 bytes regbank, but you have to save
it before use and restore the contents afterwards. Using the 6 bytes regbank
has the advantage that all subroutines will save the contents, so these
locations may be used safely when calling other library routines.

Regards


	Uz


--
Ullrich von Bassewitz                                  uz_at_musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo_at_musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.


Date view Thread view Subject view

This archive was generated by hypermail 2.1.3 : 2001-12-14 22:05:38 CET