Mail Archives: djgpp/1998/01/26/21:55:40
At 10:31 1/26/1998 +0100, d-range! wrote:
>Nate Eldredge wrote:
>
>> >My question: how can I make inline functions like this one to work with
>> >DJGPP. I read the DJGPP assembler tutorial, and I know you can #define the
>> >function like this,
>> >
>> >#define FixSHR(arg1,arg2,arg3) __asm__ \
>> > "sarl %1,%0" \
>> > : "=r" (arg3) \
>> > : "0" (arg1), "1" (arg2) \
>> > : "0";
>> Try this:
>> inline int FixSHR(int n, unsigned c)
>> {
>> int result;
>> asm ("sarl %2,%0"
>> : "=g" (result)
>> : "0" (n), "cI" (c));
>> return result;
>> }
>
>Does this produce *inline* assembly? It looks like if the compiler makes a CALL
>for every invocation.
Yes, if you include the code in each source file which uses it and compile
with `-O'.
See the info page "gcc" "C Extensions" "Inline" for more info on inline
functions. The `extern inline' syntax may be particularly helpful here.
>> Incidentally, since your operands are `int', `FixSHR(a,b)' has the same
>> effect as `a >> b'.
>
>Ah... WATCOM always does SHR instead of SAR
That's silly. A signed value should get an arithmetic shift.
Nate Eldredge
eldredge AT ap DOT net
- Raw text -