d6c369656a11db7ad13a8f53fef75fd698e5a5f5
[libfirm] / ir / be / test / asm_test.c
1 #include <stdio.h>
2
3 static inline unsigned char inb(const unsigned short port)
4 {
5     unsigned char val;
6
7     __asm__ __volatile__ ("inb  %w1, %0" : "=a"(val) : "dN"(port));
8
9     return val;
10 }
11
12 static inline void outb(const unsigned short port, const unsigned char val)
13 {
14         int k = val; /* just here to test the b modifier in %b0 */
15     __asm__ __volatile__ ("outb %b0, %1" : : "a"(k), "dN"(port));
16 }
17
18 static void sincostest(double arg)
19 {
20         double cos, sin;
21
22         __asm__ ("fsincos" : "=t"(cos), "=u"(sin) : "0" (arg));
23         printf("Arg: %f Sin: %f Cos: %f\n", arg, sin, cos);
24 }
25
26 static inline int mov(int val)
27 {
28         int res;
29
30         __asm__ ("movl %0, %1" : "=r"(res) : "ri" (val));
31
32         return res;
33 }
34
35
36 int main()
37 {
38         //sincostest(0.5);
39         //outb(123, 42);
40
41         return mov(0);
42 }