1
2 #include <stdio.h>
3
4 typedef unsigned int UInt;
5
set_fpscr(UInt x)6 void set_fpscr ( UInt x )
7 {
8 UInt d[2];
9 d[0] = 0;
10 d[1] = x;
11 __asm__ __volatile__(
12 "lfd %%f0,0(%0)\n\t"
13 "mtfsf 255,%%f0"
14 : /*out*/
15 : /*in*/ "b"(&d[0])
16 : /*trash*/ "fr0", "cc", "memory"
17 );
18
19 }
20
main(void)21 int main ( void )
22 {
23 int i;
24 UInt r;
25 for (i = 0; i < 16; i++) {
26 set_fpscr(i);
27 __asm__ __volatile__(
28 "li %0,0\n\t"
29 "mtcr %0\n\t"
30 "mcrfs 1,7\n\t"
31 "mfcr %0"
32 : /*out*/ "=b"(r)
33 : /*in*/
34 : /*trash*/ "cc"
35 );
36 printf("0x%x -> 0x%08x\n", i, r);
37 }
38 for (i = 0; i < 16; i++) {
39 set_fpscr(i);
40 __asm__ __volatile__(
41 "li %0,-1\n\t"
42 "mtcr %0\n\t"
43 "mcrfs 1,7\n\t"
44 "mfcr %0"
45 : /*out*/ "=b"(r)
46 : /*in*/
47 : /*trash*/ "cc"
48 );
49 printf("0x%x -> 0x%08x\n", i, r);
50 }
51 return 0;
52 }
53