4 long test_modsd( long srcA
, long srcB
)
7 __asm__
__volatile__ ("modsd %0,%1,%2" : "=r" (dst
): "r" (srcA
), "r" (srcB
));
12 unsigned long test_modud( unsigned long srcA
, unsigned long srcB
)
15 __asm__
__volatile__ ("modud %0,%1,%2" : "=r" (dst
): "r" (srcA
), "r" (srcB
));
20 int test_modsw( int srcA
, int srcB
)
23 __asm__
__volatile__ ("modsw %0,%1,%2" : "=r" (dst
): "r" (srcA
), "r" (srcB
));
28 unsigned test_moduw( unsigned srcA
, unsigned srcB
)
31 __asm__
__volatile__ ("moduw %0,%1,%2" : "=r" (dst
): "r" (srcA
), "r" (srcB
));
40 int srcA_si
, srcB_si
, dst_si
;
41 unsigned int srcA_ui
, srcB_ui
, dst_ui
;
42 long srcA_sl
, srcB_sl
, dst_sl
;
43 unsigned long srcA_ul
, srcB_ul
, dst_ul
;
49 #define SI_NEGATIVE_START 0x80000000
50 #define SI_NEGATIVE_STOP 0x80000008
51 #define SI_POSITIVE_START 0x7FFFFFF8
52 #define SI_POSITIVE_STOP 0x7FFFFFFF
53 #define SI_ZERO_START -5
54 #define SI_ZERO_STOP 5
56 #define DI_NEGATIVE_START 0x8000000000000000LL
57 #define DI_NEGATIVE_STOP 0x8000000000000008LL
58 #define DI_POSITIVE_START 0x7FFFFFFFFFFFFFF8LL
59 #define DI_POSITIVE_STOP 0x7FFFFFFFFFFFFFFFLL
60 #define DI_ZERO_START -5
61 #define DI_ZERO_STOP 5
63 #define UI_START 0xFFFFFFF8
64 #define UI_STOP 0xFFFFFFFF
65 #define UI_ZERO_START 0
66 #define UI_ZERO_STOP 10
68 #define UL_START 0xFFFFFFFFFFFFFFF8ULL
69 #define UL_STOP 0xFFFFFFFFFFFFFFFFULL
70 #define UL_ZERO_START 0
71 #define UL_ZERO_STOP 10
73 /* Signed tests need to check the most negative values,
74 the most positive values and values around zero. */
76 /* Signed integer tests */
77 for (i_si
= SI_NEGATIVE_START
; i_si
< SI_NEGATIVE_STOP
; i_si
++)
78 for (j_si
= SI_NEGATIVE_START
; j_si
< SI_NEGATIVE_STOP
; j_si
++)
83 dst_si
= test_modsw( srcA_si
, srcB_si
);
85 printf("srcA_si = %d \n", srcA_si
);
86 printf("srcB_si = %d \n", srcB_si
);
87 printf ("modsw result = %d\n\n", dst_si
);
89 printf ("modsw result = %d\n", dst_si
);
93 for (i_si
= SI_ZERO_START
; i_si
< SI_ZERO_STOP
; i_si
++)
94 for (j_si
= SI_ZERO_START
; j_si
< SI_ZERO_STOP
; j_si
++)
99 dst_si
= test_modsw( srcA_si
, srcB_si
);
102 printf("srcA_si = %d \n", srcA_si
);
103 printf("srcB_si = %d \n", srcB_si
);
104 printf ("modsw result = %d\n\n", dst_si
);
106 printf ("modsw result = %d\n", dst_si
);
110 for (i_si
= SI_POSITIVE_START
; i_si
< SI_POSITIVE_STOP
; i_si
++)
111 for (j_si
= SI_POSITIVE_START
; j_si
< SI_POSITIVE_STOP
; j_si
++)
116 dst_si
= test_modsw( srcA_si
, srcB_si
);
119 printf("srcA_si = %d \n", srcA_si
);
120 printf("srcB_si = %d \n", srcB_si
);
121 printf ("modsw result = %d\n\n", dst_si
);
123 printf ("modsw result = %d\n", dst_si
);
127 /* Signed long integer tests */
128 for (i_sl
= DI_NEGATIVE_START
; i_sl
< DI_NEGATIVE_STOP
; i_sl
++)
129 for (j_sl
= DI_NEGATIVE_START
; j_sl
< DI_NEGATIVE_STOP
; j_sl
++)
134 dst_sl
= test_modsd( srcA_sl
, srcB_sl
);
137 printf("srcA_sl = %ld \n", srcA_sl
);
138 printf("srcB_sl = %ld \n", srcB_sl
);
139 printf ("modsd result = %ld\n\n", dst_sl
);
141 printf ("modsd result = %ld\n", dst_sl
);
145 for (i_sl
= DI_ZERO_START
; i_sl
< DI_ZERO_STOP
; i_sl
++)
146 for (j_sl
= DI_ZERO_START
; j_sl
< DI_ZERO_STOP
; j_sl
++)
151 dst_sl
= test_modsd( srcA_sl
, srcB_sl
);
154 printf("srcA_sl = %ld \n", srcA_sl
);
155 printf("srcB_sl = %ld \n", srcB_sl
);
156 printf ("modsd result = %ld\n\n", dst_sl
);
158 printf ("modsd result = %ld\n", dst_sl
);
162 for (i_sl
= DI_POSITIVE_START
; i_sl
< DI_POSITIVE_STOP
; i_sl
++)
163 for (j_sl
= DI_POSITIVE_START
; j_sl
< DI_POSITIVE_STOP
; j_sl
++)
168 dst_sl
= test_modsd( srcA_sl
, srcB_sl
);
171 printf("srcA_sl = %ld \n", srcA_sl
);
172 printf("srcB_sl = %ld \n", srcB_sl
);
173 printf ("modsd result = %ld\n\n", dst_sl
);
175 printf ("modsd result = %ld\n", dst_sl
);
179 /* Unsigned tests need to check the most positive values
180 and the values around zero. */
182 /* Unsigned integer tests */
183 for (i_ui
= UI_START
; i_ui
< UI_STOP
; i_ui
++)
184 for (j_ui
= UI_START
; j_ui
< UI_STOP
; j_ui
++)
189 dst_ui
= test_moduw( srcA_ui
, srcB_ui
);
192 printf("srcA_ui = %u \n", srcA_ui
);
193 printf("srcB_ui = %u \n", srcB_ui
);
194 printf ("moduw result = %u\n\n", dst_ui
);
196 printf ("moduw result = %u\n", dst_ui
);
200 for (i_ui
= SI_ZERO_START
; i_ui
< SI_ZERO_STOP
; i_ui
++)
201 for (j_ui
= SI_ZERO_START
; j_ui
< SI_ZERO_STOP
; j_ui
++)
206 dst_ui
= test_moduw( srcA_ui
, srcB_ui
);
209 printf("srcA_ui = %u \n", srcA_ui
);
210 printf("srcB_ui = %u \n", srcB_ui
);
211 printf ("moduw result = %u\n", dst_ui
);
213 printf ("moduw result = %u\n\n", dst_ui
);
217 /* Unsigned long integer tests */
218 for (i_ul
= UL_START
; i_ul
< UL_STOP
; i_ul
++)
219 for (j_ul
= UL_START
; j_ul
< UL_STOP
; j_ul
++)
224 dst_ul
= test_modud( srcA_ul
, srcB_ul
);
227 printf("srcA_ul = %lu \n", srcA_ul
);
228 printf("srcB_ul = %lu \n", srcB_ul
);
229 printf ("modud result = %lu\n\n", dst_ul
);
231 printf ("modud result = %lu\n", dst_ul
);
235 for (i_ul
= UL_ZERO_START
; i_ul
< UL_ZERO_STOP
; i_ul
++)
236 for (j_ul
= UL_ZERO_START
; j_ul
< UL_ZERO_STOP
; j_ul
++)
241 dst_ul
= test_modud( srcA_ul
, srcB_ul
);
244 printf("srcA_ul = %lu \n", srcA_ul
);
245 printf("srcB_ul = %lu \n", srcB_ul
);
246 printf ("modud result = %lu\n\n", dst_ul
);
248 printf ("modud result = %lu\n", dst_ul
);
252 printf("HAS_ISA_3_00 not detected.\n");
253 #endif // HAS_ISA_3_0