Re: [cc65] Using VIC struct in inline assembler

From: Ullrich von Bassewitz <>
Date: 2011-12-01 00:06:37
Good evening!

On Wed, Nov 30, 2011 at 09:51:52PM +0100, "Andreas Rückert" wrote:
> I'm trying to do something like
> __asm__( "sta %v", VIC.spr1_x);
> , which does not work. Seems to be understandable, since VIC.spr1_x
> is a byte value and I want the address.

"VIC" is not really a C identifier, but a #define. So %v won't work. You can

        asm ("lda %w", (unsigned) &VIC.spr1_x);

instead. This calculates the address and converts it to an unsigned (since the
parser expects an integer for %w).

> What I'd actually write would be something like
> __asm__( "sta %v", VIC.spr ## SHOT_SPRITE ## _x);
> and use a define for SHOT_SPRITE, but I guess there's no chance
> to get such a construct to work?

The ## operator is valid only within the preprocessing list of a macro. And,
cc65 has some deficiencies in this area. So you can try, but I'm not sure it
will work.



Ullrich von Bassewitz                        
To unsubscribe from the list send mail to with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Thu Dec 1 00:06:45 2011

This archive was generated by hypermail 2.1.8 : 2011-12-01 00:06:48 CET