Re: [cc65] code generation

Date view Thread view Subject view

From: Groepaz (groepaz_at_gmx.net)
Date: 2003-09-16 05:33:37


ok some more.... first another bug :=P


register unsigned short x;
register unsigned char xx;

#define uaddsc(__a,__x) __asm__ ("lda %v", __x); \
	__asm__ ("clc"); \
	__asm__ ("adc %v", __a);

uaddsc(x,xx);

gives me "identifier expected for argument 1" for the first line of the macro 
(it works with __a instead of __x)

then ... i found a great intermediate solution for the local-labels-in-macros 
problem :o) the idea is, that there already exists a counter that is (or 
better, can be arranged to) increment at each macro expansion... it is the 
__LINE__ symbol :) consider this macro (which lead me to the above bug :P)

#define uaddsc(__a,__x) __asm__ ("lda %v", __a); \
	__asm__ ("clc"); \
	__asm__ ("adc %v", __x); \
	__asm__ ("sta %v", __a); \
	__asm__ ("bcc @%w", __LINE__); \
	__asm__ ("inc %v+1", __a); \
	__asm__ ("@%w:", __LINE__);
	
this will work great, with the limitation of one macro per line, and no macros 
as args that use that kind of trick by themselves.... it even compiles with 
--feature dollar_in_identifiers (if you make __x __a) :=)

for this (and maybe other things) some feature in the inline assembler to get 
rid of the dollar-sign might come in handy :)

gpz

----------------------------------------------------------------------
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 : 2003-09-16 05:38:49 CEST