Re: [cc65] c64 question

Date view Thread view Subject view

From: Mike McCarty (jmccarty_at_ssd.usa.alcatel.com)
Date: 2001-03-19 20:12:41


On Sat, 10 Mar 2001, Ullrich von Bassewitz wrote:

> 
> 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.

Which could be solved by disabling interrupts.

Mike
----
char *p="char *p=%c%s%c;main(){printf(p,34,p,34);}";main(){printf(p,34,p,34);}
This message made from 100% recycled bits.
I can explain it for you, but I can't understand it for you.
I don't speak for Alcatel      <- They make me say that.

----------------------------------------------------------------------
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