X-Git-Url: http://nsz.repo.hu/git/?a=blobdiff_plain;f=ir%2Fbe%2Ftest%2Fasm_test.c;h=d5fe607fa3f5dc2c5487eea94fad6923fe07a278;hb=472ccfce16a006cff42fc12e463e1d5a2d1a8de4;hp=cce98598dc9e2a7d2eba1f273024ad1ba04fd6f7;hpb=c1bd563c516a4540b6e4db0a4e456c0f64c70650;p=libfirm diff --git a/ir/be/test/asm_test.c b/ir/be/test/asm_test.c index cce98598d..d5fe607fa 100644 --- a/ir/be/test/asm_test.c +++ b/ir/be/test/asm_test.c @@ -1,5 +1,7 @@ #include +#include +#ifdef __i386__ static inline unsigned char inb(const unsigned short port) { unsigned char val; @@ -32,12 +34,66 @@ static inline int mov(int val) return res; } +static inline unsigned short swap16(unsigned short x) +{ + __asm__("xchgb %b0, %h0 /* in: %1 out: %0 */" : "=q" (x) : "0" (x)); + return x; +} -int main() +static inline unsigned int swap32(unsigned int x) +{ + __asm__("bswap %0 /* %1 */" : "=r" (x) : "0" (x)); + return x; +} + +#if 1 +typedef struct kernel_fd_set { + int bla; + int blup; +} kernel_fd_set; +#else +typedef int kernel_fd_set; +#endif + +void fd_set(int fd, kernel_fd_set* set) { + __asm__("btsl %1,%0" : "=m" (*(set)) : "r" (fd)); +} + +int fd_isset(int fd, kernel_fd_set *set) { + unsigned char result; + + __asm__ __volatile__("btl %1,%2\n" + "\tsetb %0" + : "=q" (result) + : "r" (fd), "m" (*set)); + return result; +} + +int justcompile(void) { - //sincostest(0.5); outb(123, 42); outb(12345, 42); + return inb(20) + inb(5); +} + +int main() +{ + kernel_fd_set s; + + fd_set(20, &s); + assert(fd_isset(20, &s)); + + printf("Swap16: %d Swap32: %d\n", swap16(12), swap32(123551235)); - return mov(0) + inb(12345) + inb(123); + return mov(0); } + +#else + +int main() +{ + printf("Warning: asmtest only work on x86\n"); + return 0; +} + +#endif