C Macro with asm

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 
3,678件の閲覧回数
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

ラベル(1)
0 件の賞賛
返信
1 解決策
1,341件の閲覧回数
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 件の賞賛
返信
4 返答(返信)
1,341件の閲覧回数
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 件の賞賛
返信
1,341件の閲覧回数
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 件の賞賛
返信
1,342件の閲覧回数
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 件の賞賛
返信
1,341件の閲覧回数
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 件の賞賛
返信