C Macro with asm

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

C Macro with asm

跳至解决方案
3,679 次查看
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,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 项奖励
回复
4 回复数
1,342 次查看
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,342 次查看
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,343 次查看
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,342 次查看
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 项奖励
回复