Re: __asm__

Richard B. Johnson (root@chaos.analogic.com)
Fri, 16 Jul 1999 09:12:26 -0400 (EDT)


On Fri, 16 Jul 1999, Colin Coe wrote:

> Hi all
>
> How would I use the __asm__ macro to execute to following assember?
>
> mov ax, <some_variable>
> mov es, ax
> sub ax, ax
> xchg ax, es:[<some_variable>]
>

The gcc asm uses the ATT command-set. Therefore it's backwards from
Intel Assembler.

The asm extension puts text into the intermediate code that gcc
generates, i.e., do `gcc -S -o att.asm program.c`. The result is
that you have to put in some '%' characters to show that registers
are registers. There are numerous examples of such assembler in
../linux/arch/i386/* and ../linux/include/asm/*.h

FYI, your code snippet above sets a segment register from the contents
of some memory operand. This is something that you probably don't want
to do in Linux. If you do, you move it directly :

mov es, [some_variable]

Cheers,
Dick Johnson
FILE SYSTEM MODIFIED
Penguin : Linux version 2.2.6 on an i686 machine (400.59 BogoMips).
Warning : It's hard to remain at the trailing edge of technology.

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/