Re: [cc65] Assembler code in C

From: Spiro Trikaliotis <>
Date: 2004-03-20 15:23:53
Hi Uz,

* On Fri, Mar 19, 2004 at 06:59:52PM +0100 Ullrich von Bassewitz wrote:
>    	void Int0 (void)
>    	{
>    	    asm ("cld");
>    	    {
>    		unsigned char status;
>    		status = foo (bar);
>    		...
>    	    }
>    	}
>    Since the variables are placed on the stack, this type of function is still
>    reentrant (the one from 1. is not).

I'm surprised about this behaviour, so I just did some quick test (see
attached file).

I would have thought that function a() would generate almost the same
code as function b(), but "reuse" the memory for variable b with
variable c. As I see in the assembler output, this is not the case.
Instead, the stack is manipulated twice, once when a block is left and 
once when the new block is entered.

I know other C compilers (a "little" bit bigger than cc65, like MSVC)
analyse the full function, reserve enough memory for *every* block
inside at the beginning of the function, and just dynamically adapt the
usage of this memory when entering and leaving blocks. This way, the
stack has to be manipulated only once. Isn't this possible with CC65?
Does it need too much analysis?

Best regards,

Spiro R. Trikaliotis

To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Sat Mar 20 15:24:50 2004

This archive was generated by hypermail 2.1.8 : 2004-03-20 15:24:56 CET