1 #include <stdio.h>
2
3 /* Test various BFP ops:
4 - square root
5 - load negative
6 - load positive
7 - load complement
8 */
9
sqebr(float in)10 void sqebr(float in)
11 {
12 float out;
13
14 __asm__ volatile("sqebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
15 printf("sqebr %f -> %f\n", in, out);
16 }
17
sqdbr(double in)18 void sqdbr(double in)
19 {
20 double out;
21
22 __asm__ volatile("sqdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
23 printf("sqdbr %f -> %f\n", in, out);
24 }
25
lnebr(float in)26 void lnebr(float in)
27 {
28 float out;
29
30 __asm__ volatile("lnebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
31 printf("lnebr %f -> %f\n", in, out);
32 }
33
lndbr(double in)34 void lndbr(double in)
35 {
36 double out;
37
38 __asm__ volatile("lndbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
39 printf("lndbr %f -> %f\n", in, out);
40 }
41
lpebr(float in)42 void lpebr(float in)
43 {
44 float out;
45
46 __asm__ volatile("lpebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
47 printf("lpebr %f -> %f\n", in, out);
48 }
49
lpdbr(double in)50 void lpdbr(double in)
51 {
52 double out;
53
54 __asm__ volatile("lpdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
55 printf("lpdbr %f -> %f\n", in, out);
56 }
57
lcebr(float in)58 void lcebr(float in)
59 {
60 float out;
61
62 __asm__ volatile("lcebr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
63 printf("lcebr %f -> %f\n", in, out);
64 }
65
lcdbr(double in)66 void lcdbr(double in)
67 {
68 double out;
69
70 __asm__ volatile("lcdbr %[out],%[in]" : [out]"=f"(out) : [in]"f"(in));
71 printf("lcdbr %f -> %f\n", in, out);
72 }
73
lder(double prev,float in)74 void lder(double prev, float in)
75 {
76 unsigned long out;
77
78 __asm__ volatile("lder %[prev],%[in]\n\t"
79 "std %[prev],%[out]" :
80 [out]"=R"(out) : [prev]"f"(prev), [in]"f"(in));
81 printf("lder %f -> %lx\n", in, out);
82 }
83
lde(double prev,float in)84 void lde(double prev, float in)
85 {
86 unsigned long out;
87
88 __asm__ volatile("lde %[prev],%[in]\n\t"
89 "std %[prev],%[out]" :
90 [out]"=R"(out) : [prev]"f"(prev), [in]"R"(in));
91 printf("lde %f -> %lx\n", in, out);
92 }
93
main(void)94 int main(void)
95 {
96 // square root
97 sqebr(121.0f); // 4 byte values
98 sqdbr(144.0); // 8 bytes values
99
100 // load negative
101 lnebr(-2.5f); // 4 byte values
102 lnebr(12.5f); // 4 byte values
103
104 lndbr(-0.5); // 8 byte values
105 lndbr(42.5); // 8 byte values
106
107 // load positive
108 lpebr(-2.5f); // 4 byte values
109 lpebr(12.5f); // 4 byte values
110
111 lpdbr(-0.5); // 8 byte values
112 lpdbr(42.5); // 8 byte values
113
114 // load complement
115 lcebr(-23.5f); // 4 byte values
116 lcebr(123.5f); // 4 byte values
117
118 lcdbr(-17.5); // 8 byte values
119 lcdbr(234.5); // 8 byte values
120
121 // load lengthened
122 lder(0.2, 321.5f);
123 lder(0.9, -8388607.f);
124 lde(0.2, -321.5f);
125 lde(0.9, 8388607.f);
126
127 return 0;
128 }
129