inline asm

inline asm

Post by highlan » Sun, 30 Mar 2003 21:45:01



Hello
        How can i use assembler in my C program (kompiled under gcc) ?
Could anybody give any example ?

Thanx
Michal

 
 
 

inline asm

Post by Basile STARYNKEVITC » Sun, 30 Mar 2003 22:17:40


    highland> Hello How can i use assembler in my C program (kompiled
    highland> under gcc) ?  Could anybody give any example ?

The info pages for GCC document in details the use of the extended asm
directive.

The linux kernel sources use extensively these, so constitute a good
example.

See also the Linux Assembly HOWTO.

--

Basile STARYNKEVITCH         http://starynkevitch.net/Basile/
email: basile<at>starynkevitch<dot>net
aliases: basile<at>tunes<dot>org = bstarynk<at>nerim<dot>net
8, rue de la Fa?encerie, 92340 Bourg La Reine, France

 
 
 

inline asm

Post by Paul Taylo » Tue, 01 Apr 2003 15:48:10



> Hello
>    How can i use assembler in my C program (kompiled under gcc) ?
> Could anybody give any example ?

> Thanx
> Michal

See linuxassembly.org

Regards,

PT

 
 
 

1. inline asm errors when compiling linux-1.2.13 with gcc-2.7.1

Hello,

I've run into problems compiling the linux-1.2.13 kernel, which
always worked fine for me. I suspect the problem is not the
kernel, but gcc. I recently upgraded my gcc to version 2.7.1
(homebuilt from GNU sources, linux-aout configuration). When I
try to build the kernel, I get:

ZOO-station:/usr/src/linux# make zlilo
gcc -D__KERNEL__ -I/usr/src/linux/include -Wall
-Wstrict-prototypes -O2 -fomit-frame-pointer -pipe -m486  -c -o
init/main.o init/main.c
/usr/src/linux/include/asm/io.h: In function `copro_timeout':
/usr/src/linux/include/asm/io.h:82: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h:82: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h:82: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h:82: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h: In function `check_fpu':
/usr/src/linux/include/asm/io.h:78: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h:82: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h:78: inconsistent operand
constraints in an `asm'
/usr/src/linux/include/asm/io.h:82: inconsistent operand
constraints in an `asm'
make: *** [init/main.o] Error 1
ZOO-station:/usr/src/linux#

So, did gcc-2.7.1 chenge the syntax for inline asm?
Does anybody have the same problems, or know how to fix this?

The offending part from linux/include/asm/io.h:

73: #define __OUTS(s) \
74: extern inline void outs##s(unsigned short port, const void *
addr, unsigned long count) \
75: { __asm__ __volatile__ ("cld ; rep ; outs" #s \
76: : "=S" (addr), "=c" (count) : "d" (port),"0" (addr),"1"
(count)); }
77:
78: __IN(b,"b","0" (0))
79: __IN(w,"w","0" (0))
80: __IN(l,"")
81:
82: __OUT(b,"b",char)
83: __OUT(w,"w",short)
84: __OUT(l,,int)
85:
86: __INS(b)
87: __INS(w)
88: __INS(l)
89:
90: __OUTS(b)
91: __OUTS(w)
92: __OUTS(l)

BTW: The ftape module, which also never gave me troubles, gives
about the
same errors.

Happy hacking,
          JanJaap

2. SPARC file dates

3. gcc inline asm - short question

4. GnuPG GUI for KDE2

5. PIII-instruction SHUFPS with gcc-inline-asm

6. I missed the SUMMARY-post

7. Linux-1.0-inline-asm uploaded

8. Sound / CDROM setup (beginner)

9. C inline ASM IN/OUT operation

10. Inline asm on Ultrasparc: FP register pairs?

11. help with inline asm()

12. PIII-instruction SHUFPS with gcc-inline-asm

13. How to get inline asm for Hitachi Sh2