Article View: gnu.gcc.help
Article #51770Please help with gcc inline asm
From: Kingsley Turner
Date: Fri, 26 Mar 1993 19:19
Date: Fri, 26 Mar 1993 19:19
37 lines
2173 bytes
2173 bytes
/* Fill the buffer pointed to by s, with c, n times. */
inline void Memset (void *s, int c, int n){
asm (
"movl %1, %%edi\n"
"movl %2, %%eax\n"
"movl %3, %%ecx\n"
"movb %%al, %%ah\n"
"movl %%eax, %%edx\n"
"shll $16, %%eax\n"
"movw %%dx, %%ax\n"
"shrl $2, %%ecx\n"
"rep\n"
"stosl\n"
"movl %3, %%ecx\n"
"andl $3, %%ecx\n"
"rep\n"
"stosb\n"
: "g" (s), "g" (c), "g" (n)
: "edi", "eax", "ecx", "edx"
);
}
This is a non-working memset function. If I add a local variable
int x, and add ': "=g" (x)' before the other ':' lines it will compile and
work so long as I don't compile with -O or -O2. (btw: on 486dx33 8MB under
OS2-2.0). I have no idea or docs, only another single function to try to
work out the format from. Please, why won't it work when compiled with -O2
I looked at the asm output and it compiled to a seperate function that was
little more than begin-return.
and what do I have to put in so it don't need to have temporary variables.
I *need* it to be fast, and before u cry 'but its only 1 squillonth of a sec'
i reckon every little bit counts. (and it does)
If there is some sort of doc file on this could someone please send
&/| post it please. The function body itself i lifted from memset.s in my
lib source, so there aint nothing wrong with that.
Kingsley Turner
Technical Details
Message-ID:
<1993Mar26.191923.3748@scorch.apana.org.au>Path:
arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!seagoon.newcastle.edu.au!scorch!kinturShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 11318c,c0fab1eb845a7d,start X-Google-Attributes: gid11318c,public X-Google-ArrivalTime: 1993-03-26 17:41:20 PST Newsgroups: gnu.gcc.help Path: arc1-ca.pugleaf.net!sparky!uunet!munnari.oz.au!metro!seagoon.newcastle.edu.au!scorch!kintur From: kintur@scorch.apana.org.au (Kingsley Turner) Subject: Please help with gcc inline asm Organization: Craggenmoore public Unix system , Newcastle , Oz Date: Fri, 26 Mar 1993 19:19:23 GMT Message-ID: <1993Mar26.191923.3748@scorch.apana.org.au> Summary: need help with inline asm under gcc Keywords: inline asm Lines: 38