Re: [cc65] c64 question

Date view Thread view Subject view

From: Ullrich von Bassewitz (uz_at_musoftware.de)
Date: 2001-03-10 11:02:35


On Sat, Mar 10, 2001 at 10:53:33AM +0100, Arvid Norberg wrote:
> I see what you mean. But isn't the stack pointer increamented
> automatically by pha?

The hardware stack of the 6502 (in page 1) is really limited. 256 bytes are
right to nothing for a high level language. Assume you have a C function with
50 bytes of parameters and local variables (which is not much). Five recursive
calls to this function plus an interrupt would then blow up the stack.

So cc65 is actually using two stacks: For return addresses, the hardware stack
is used. For function parameters, local variables and other stuff, a separate
software stack (also called "C stack") is used.

What I was talking about is the software stack. To manage this stack, the
runtime modules use a software stack pointer located in the zero page.
Incrementing or decrementing this variable is no atomic operation, so there is
a problem with reentrancy.

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:39 CET