Return to BSD News archive
Newsgroups: comp.os.386bsd.development
Path: sserve!newshost.anu.edu.au!munnari.oz.au!foxhound.dsto.gov.au!fang.dsto.gov.au!yoyo.aarnet.edu.au!news.adelaide.edu.au!news.cs.su.oz.au!harbinger.cc.monash.edu.au!yeshua.marcam.com!MathWorks.Com!europa.eng.gtefsd.com!howland.reston.ans.net!xlink.net!subnet.sub.net!flatlin!bad
From: bad@flatlin.ka.sub.org (Christoph Badura)
Subject: Re: Gnu Inline Assembly question
Date: Sun, 10 Apr 1994 20:01:20 GMT
Message-ID: <Co27M9.C66@flatlin.ka.sub.org>
References: <2n76gvINNbjn@uwm.edu> <3105@adagio.lemis.uucp>
Organization: Guru Systems/Funware Department
Lines: 54
In <3105@adagio.lemis.uucp> grog@lemis.uucp (Greg Lehey) writes:
>In article <2n76gvINNbjn@uwm.edu> knier@miller.cs.uwm.edu (Robert Knier ) writes:
>> Does any one have info on inline assembly with the gnu compiler?
Yes.
>Read the gcc documentation. It is not as simple as it might appear: in
>particular, you need to supply parameters and type information.
Good advice. Read the documentation carefully and be sure to verify
your asms by running gcc -S and looking at the output.
Here are some working samples culled from FAS-2.11.1.
#if defined (__GNUC__) && !defined (NO_ASM)
#if defined (XENIX)
/* This Xenix version works for gcc-1.37 and gcc-1.4x and gas-1.3x */
#define OUTB(port,val) \
({\
__asm__ volatile ("outb %%al,%%dx" : : "d" ((uint) (port)), "a" ((unchar) (val)));\
})
#define INB(port) \
({\
unchar __val;\
__asm__ volatile ("inb %%dx,%%al" : "=a" (__val) : "d" ((uint) (port)));\
__val;\
})
#endif /* XENIX */
/* This ones seems to require GCC-2. I've couldn't be bother to
* convert it to GCC-1 */
#define FAS_MEM_COPY(dst,src,n) \
({\
__asm__ volatile ("movl %2,%%ecx\n"\
"\tcld\n"\
"\tshrl $2,%%ecx\n"\
"\trep\n"\
"\tmovsl\n"\
"\tmovl %2,%%ecx\n"\
"\tandl $3,%%ecx\n"\
"\trep\n"\
"\tmovsb" : : "D" ((unchar *) (dst)),\
"S" ((unchar *) (src)),\
"r" ((uint) (n))\
: "D", "S", "c", "cc");\
})
--
Christoph Badura bad@flatlin.ka.sub.org +49 721 606137
Es genuegt nicht, keine Gedanken zu haben;
man muss auch unfaehig sein, sie auszudruecken. - Karl Kraus