4 static inline unsigned char inb(const unsigned short port)
8 __asm__ __volatile__ ("inb %w1, %0" : "=a"(val) : "dN"(port));
13 static inline void outb(const unsigned short port, const unsigned char val)
15 int k = val; /* just here to test the b modifier in %b0 */
16 __asm__ __volatile__ ("outb %b0, %1" : : "a"(k), "dN"(port));
19 static void sincostest(double arg)
23 __asm__ ("fsincos" : "=t"(cos), "=u"(sin) : "0" (arg));
24 printf("Arg: %f Sin: %f Cos: %f\n", arg, sin, cos);
27 static inline int mov(int val)
31 __asm__ ("movl %1, %0" : "=r"(res) : "ri" (val));
36 static inline unsigned short swap16(unsigned short x)
38 __asm__("xchgb %b0, %h0 /* in: %1 out: %0 */" : "=q" (x) : "0" (x));
42 static inline unsigned int swap32(unsigned int x)
44 __asm__("bswap %0 /* %1 */" : "=r" (x) : "0" (x));
54 printf("Swap16: %d Swap32: %d\n", swap16(12), swap32(123551235));
56 return mov(0) /*+ inb(12345) + inb(123)*/;
63 printf("Warning: asmtest only work on x86\n");