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
main(void)74 int main(void)
75 {
76 // square root
77 sqebr(121.0f); // 4 byte values
78 sqdbr(144.0); // 8 bytes values
79
80 // load negative
81 lnebr(-2.5f); // 4 byte values
82 lnebr(12.5f); // 4 byte values
83
84 lndbr(-0.5); // 8 byte values
85 lndbr(42.5); // 8 byte values
86
87 // load positive
88 lpebr(-2.5f); // 4 byte values
89 lpebr(12.5f); // 4 byte values
90
91 lpdbr(-0.5); // 8 byte values
92 lpdbr(42.5); // 8 byte values
93
94 // load complement
95 lcebr(-23.5f); // 4 byte values
96 lcebr(123.5f); // 4 byte values
97
98 lcdbr(-17.5); // 8 byte values
99 lcdbr(234.5); // 8 byte values
100
101 return 0;
102 }
103