Re: [x86 inline asm]: width of register arguments

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 7/2/19 6:37 AM, Zdenek Sojka wrote:
> Ok, shame - it seems to behave so in my experiments:

It's more complicated than that. Sometimes the size of the operand is
in the name of the instruction and sometimes you need to force the
size yourself.

For example, with int a, x:

  asm("mov %1, %0" : "=&r"(a) : "r"(x));

generates

	mov %edx, %eax

but

  asm("mov %b1, %b0" : "=&r"(a) : "r"(x));

generates

	mov %dl, %al

For a real-world example,

static __inline void
outb_p (unsigned char __value, unsigned short int __port)
{
  __asm__ __volatile__ ("outb %b0,%w1\noutb %%al,$0x80": :"a" (__value),
                  "Nd" (__port));
}

On x86 the special asm out single letter directives following a '%'
are defined in i386.md.

I'm a bit paranoid about this stuff because my memory of GCC's inline
asm goes back decades to when it was far more fragile than it is now.

-- 
Andrew Haley  (he/him)
Java Platform Lead Engineer
Red Hat UK Ltd. <https://www.redhat.com>
https://keybase.io/andrewhaley
EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux