Mail Archives: djgpp/1997/01/28/06:00:34
From: | "Edgar Allan Tu" <edgar AT key DOT com>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | gcc inline assembly syntax
|
Date: | 28 Jan 1997 03:46:40 GMT
|
Organization: | Nanospace
|
Lines: | 36
|
Message-ID: | <01bc0ccf$cef8b2a0$80c4c7cd@etu.planetweb>
|
NNTP-Posting-Host: | 205.199.196.128
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Hi masters of gnu syntax,
I'm new to doing inline assembly in gnu C. I'm try to do a code like this:
#define FIXMUL(a,b) ( \
{ \
long _result; \
asm ( \
"imull %%ebx\n\t" \
"shld $16,%%eax\n\t"); \
__result; \
}
I can't seem to figure out how to assign my params a to eax, b to ebx and
my return code in edx to __result. The only way I was able to do this was
to do the following:
#define FIXMUL(a, b) ( \
{ \
long __result; \
asm ( \
"movl %2,%%ebx\n\t" \
"movl %1,%%eax\n\t" \
"imull %%ebx\n\t" \
"shld $16,%%eax,%%edx\n\t" \
"movl %%edx,%0" \
: "=g" (__result) \
: "g" (a), "g" (b) \
: "%ebx","%eax","%edx"); \
__result; \
})
Is there an easier way to do this? The second way adds a lot of
unnecessary code which defeats my purpose of writing this in assembly to
speed things up. Anyone? Anyone?
Thanks in advance,
Edgar Tu
- Raw text -