Re: [cc65] Assembler code in C

From: Ullrich von Bassewitz <>
Date: 2004-03-19 18:59:52

On Fri, Mar 19, 2004 at 08:46:10AM -0500, Apple2Stuff wrote:
> Is there a way to force the complier to place the CLD before the jsr decsp1?

The decsp1 is caused by the declaration of a local variable, which preceeds
the asm() statement. So it is logical that the compiler will keep the order of
both statements in the generated code.

There are two ways to work around this:

1. You can avoid decaring local variables on the stack. If the function does
   not need to be reentrant, this can be done by using

	#pragma staticlocals(on)

   which will cause the compiler to use static storage for the variables. This
   will also generate faster code.

2. Declare the variables after the asm() statement. To do that, you need a
   little trick. Just start a new block:

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



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Fri Mar 19 18:59:57 2004

This archive was generated by hypermail 2.1.8 : 2004-03-19 19:00:03 CET