Mail Archives: djgpp/1996/11/22/18:53:18
I'm trying to convert a macro that does a fixed-point divide. It
was originally written in watcom's inline asm syntax, and all my attempts
to get the code to work properly under djgpp have failed.
This was the original routine:
typedef long fp14
fp14 fpDiv(fp14 d1, fp14 d2);
#pragma aux fpDiv = \
"cdq" \
"shld edx, eax, 14" \
"sal eax,14" \
"idiv ebx" \
parm [eax] [ebx]\
modify [edx] \
value [eax];
And this was how I tried to convert it:
extern __inline__ fp14 fpDiv(fp14 d1, fp14 d2)
{
long retval=0;
__asm__ __volatile__("cdq \n" <- djgpp says this isn't a valid 386
opcode
"shl $14, %%eax \n" <- same for shld; and I
couldn't get
"shl $14, %%edx \n" both on the same line
"sal $14, %%eax \n"
"idiv %%ebx \n"
: "=a" (retval)
: "a" (d1), "b" (d2)
: "dx");
return retval;
}
- Raw text -