inline assembler
Falk Hueffner
falk.hueffner@student.uni-tuebingen.de
Wed Nov 5 18:04:00 GMT 2003
y2bismil@engmail.uwaterloo.ca writes:
> I was wondering about inline assember. I've been reading up quite a bit on it,
> and have noticed a common pattern to 'emulate' functions.
> ***************************************
> example from:
> http://www.delorie.com/djgpp/doc/brennan/brennan_att_inline_djgpp.html
> ***************************************
> #define times3(arg1, arg2) \
> __asm__ ( \
> "leal (%0,%0,2),%0" \
> : "=r" (arg2) \
> : "0" (arg1) );
> ***************************************
>
> Is there a way in inline assembler to do 'real' functions? As an example
> suppose I have the following:
> #define times3(arg1)__asm__ (...); /*this results in arg1*3*/
>
> Would there be a way for me to say
> int x = times3(arg1);
Just define an inline function:
static inline int times3(int x) {
int r;
asm(...);
return r;
}
--
Falk
More information about the Gcc-help
mailing list