5 static inline unsigned char inb(const unsigned short port)
9 __asm__ __volatile__ ("inb %w1, %0" : "=a"(val) : "dN"(port));
14 static inline void outb(const unsigned short port, const unsigned char val)
16 int k = val; /* just here to test the b modifier in %b0 */
17 __asm__ __volatile__ ("outb %b0, %1" : : "a"(k), "dN"(port));
20 static void sincostest(double arg)
24 __asm__ ("fsincos" : "=t"(cos), "=u"(sin) : "0" (arg));
25 printf("Arg: %f Sin: %f Cos: %f\n", arg, sin, cos);
28 static inline int mov(int val)
32 __asm__ ("movl %1, %0" : "=r"(res) : "ri" (val));
37 static inline unsigned short swap16(unsigned short x)
39 __asm__("xchgb %b0, %h0 /* in: %1 out: %0 */" : "=q" (x) : "0" (x));
43 static inline unsigned int swap32(unsigned int x)
45 __asm__("bswap %0 /* %1 */" : "=r" (x) : "0" (x));
50 typedef struct kernel_fd_set {
55 typedef int kernel_fd_set;
58 void fd_set(int fd, kernel_fd_set* set) {
59 __asm__("btsl %1,%0" : "=m" (*(set)) : "r" (fd));
62 int fd_isset(int fd, kernel_fd_set *set) {
65 __asm__ __volatile__("btl %1,%2\n"
68 : "r" (fd), "m" (*set));
76 return inb(20) + inb(5);
84 assert(fd_isset(20, &s));
86 printf("Swap16: %d Swap32: %d\n", swap16(12), swap32(123551235));
95 printf("Warning: asmtest only work on x86\n");