grub-devel
[Top][All Lists]
Advanced

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

Re: Endianness macros capitalization


From: Pavel Roskin
Subject: Re: Endianness macros capitalization
Date: Fri, 11 Jul 2008 05:07:58 -0400
User-agent: Internet Messaging Program (IMP) H3 (4.1.4)

Quoting Pavel Roskin <address@hidden>:

366976  original
364988  "=q", xchgb
365460  "=q", rolw $8,%w0
365420  "=r", rolw $8,%w0
364996  monstrosity ("=r", conditional xchgb/rolw)
364728  "little details"

Marginally better (by just 12 bytes):
364716  "little details" + "monstrosity"

#define grub_swap_lo(x) \
({ \
  grub_uint32_t _x = (x), _y; \
  asm ( \
       ".ifc %0,%%eax\n" \
       "xchgb %b0,%h0\n" \
       ".else\n" \
       ".ifc %0,%%ebx\n" \
       "xchgb %b0,%h0\n" \
       ".else\n" \
       ".ifc %0,%%ecx\n" \
       "xchgb %b0,%h0\n" \
       ".else\n" \
       ".ifc %0,%%edx\n" \
       "xchgb %b0,%h0\n" \
       ".else\n" \
       "rolw $8,%w0\n" \
       ".endif\n" \
       ".endif\n" \
       ".endif\n" \
       ".endif\n" \
       : "=r"(_y) : "0"(_x) \
   ); \
   _y; \
})
#define grub_swap_hi(x) \
({ \
  grub_uint32_t _x = (x), _y; \
  asm ( \
       "roll $0x10,%0\n" \
       : "=r"(_y) : "0"(_x) \
   ); \
   _y; \
})
#define grub_swap_bytes32(x) grub_swap_lo(grub_swap_hi(grub_swap_lo(x)))

--
Regards,
Pavel Roskin




reply via email to

[Prev in Thread] Current Thread [Next in Thread]