C Macro with asm

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

C Macro with asm

Jump to solution
2,773 Views
Nouchi
Senior Contributor II
Hello,

here's my C macro

Code:
volatile uint32 myVar;#define myMACRO() asm {\  TST.L myVar\  BEQ LABEL\  ADD.L %-1,myVar\LABEL:\   }
I would like to know how to to genarate unique label each time the macro is used, I tried "\@" after label name but it doesn't work.
What's the right syntax ?

tahnks

Labels (1)
0 Kudos
1 Solution
436 Views
Nouchi
Senior Contributor II
Hi, The right syntax is in the header files: Code:
extern volatile uint32 myVar;inline asm void myFunction(void){  TST.L myVar  BEQ LABEL  ADD.L %-1,myVarLABEL:}#define myMACRO() myFunction()
Emmanuel,

View solution in original post

0 Kudos
4 Replies
436 Views
ynaught
Contributor III
I don't know what your compiler is, but GCC has a Very Useful Feature that allows silliness like:
 
#define myMACRO() asm {\
 TST.L myVar\
 BEQ 1f\
 ADD.L %-1,myVar\
1:\
  }
 
It appears in this case to search forward ( indicated by the 'f' ) for the next label 1:  ... I really like this in that it frees you from coming up with unique labels for landing points within subroutines, which you'd never call from outside.
 
I have NO IDEA if other compilers allow this.
 
0 Kudos
436 Views
Nouchi
Senior Contributor II
Hello,

Sorry, I forgot to mention that it was CodeWarrior 6.3 for ColdFire.
I think that CW documentation isn't clear enough about asm macro.
This kind of feature seems only works with in lined asm function in CodeWarrior.


Emmanuel
0 Kudos
437 Views
Nouchi
Senior Contributor II
Hi, The right syntax is in the header files: Code:
extern volatile uint32 myVar;inline asm void myFunction(void){  TST.L myVar  BEQ LABEL  ADD.L %-1,myVarLABEL:}#define myMACRO() myFunction()
Emmanuel,
0 Kudos
436 Views
Nouchi
Senior Contributor II
Somebody has an idea ?
Can I use branch relative instructions inside C macro ?


Emmanuel

Message Edited by BugMan on 2006-10-2504:02 PM

0 Kudos