the code like this: unsigned short swap16(unsigned short x) { asm volatile ("xchgb %b0, %h0" : "=q" (x) : "0" (x)); return x; } produces: swap16: xchgb %dil, %di <== %di isn't valid high 8-bit form. movzwl %di, %eax ret IIRC the %rdi, %rsi, %rsp, %rbp haven't a high 8-bit form.
"`a', b, c, or d register for the i386. For x86-64 it is equivalent to `r' class (for 8-bit instructions that do not use upper halves). "
in online docs i see that "q" means "byte addressable register (a,b,c,d)". in i386.h i see something differ for x86_64. did i miss something in docs? #define REG_CLASS_FROM_LETTER(C) \ ((C) == 'r' ? GENERAL_REGS : \ (C) == 'R' ? LEGACY_REGS : \ (C) == 'q' ? TARGET_64BIT ? GENERAL_REGS : Q_REGS : \ ^^^^^^^^^^^^^^^^^^^^^^^^^^^ (C) == 'Q' ? Q_REGS : \
(In reply to comment #2) > in online docs i see that "q" means "byte addressable register (a,b,c,d)". > in i386.h i see something differ for x86_64. did i miss something in docs? Yes see comment #1 which is a quote from the docs.
(In reply to comment #3) > (In reply to comment #2) > > in online docs i see that "q" means "byte addressable register (a,b,c,d)". > > in i386.h i see something differ for x86_64. did i miss something in docs? > > Yes see comment #1 which is a quote from the docs. ohh, i should fix my /dev/brain :) i'll use the "=Q" format.