1 #include "/usr/include.orig/signal.h"
5 unsigned fp_res
[3], em_res
[3]; /* place for the result */
6 unsigned curproc
; /* not used */
20 char *name
; /* MIPS opcode name */
21 int nargs
; /* number of integer arguments needed */
22 int nresult
; /* number of integer words for the result */
79 * Read test vectors from file and test the fp emulation by
80 * comparing it with the hardware.
88 register struct optab
*op
;
92 signal(SIGFPE
, SIG_IGN
);
93 for (lineno
= 1; ; lineno
++) {
104 if (buf
[0] == '\0') {
109 for (op
= optab
; op
->name
; op
++) {
110 if (strcmp(op
->name
, buf
) == 0)
113 fprintf(stderr
, "line %d: unknown operation '%s'\n",
119 if (scanf("%x", &arg
[0]) != 1) {
120 fprintf(stderr
, "line %d: expected 1 arg\n",
124 arg
[1] = arg
[2] = arg
[3] = 0;
127 if (scanf("%x %x", &arg
[0], &arg
[2]) != 2) {
128 fprintf(stderr
, "line %d: expected 2 args\n",
132 if (op
->nresult
== 1) {
136 } else if (op
->nresult
== 2) {
144 if (scanf("%x %x %x %x", &arg
[1], &arg
[0],
145 &arg
[3], &arg
[2]) != 4) {
146 fprintf(stderr
, "line %d: expected 4 args\n",
154 dofp(c
, arg
[0], arg
[1], arg
[2], arg
[3]);
155 emfp(c
, arg
[0], arg
[1], arg
[2], arg
[3]);
157 switch (op
->nresult
) {
159 if (fp_res
[2] != em_res
[2]) {
160 printf("line %d: (%d) %s %x,%x %x,%x\n",
162 arg
[0], arg
[1], arg
[2], arg
[3]);
163 printf("\tcsr %x != %x\n",
164 fp_res
[2], em_res
[2]);
168 if (fp_res
[0] != em_res
[0] ||
169 fp_res
[2] != em_res
[2]) {
170 printf("line %d: (%d) %s %x,%x %x,%x\n",
172 arg
[0], arg
[1], arg
[2], arg
[3]);
173 printf("\t%x != %x (csr %x %x)\n",
174 fp_res
[0], em_res
[0],
175 fp_res
[2], em_res
[2]);
179 if (fp_res
[0] != em_res
[0] ||
180 fp_res
[1] != em_res
[1] ||
181 fp_res
[2] != em_res
[2]) {
182 printf("line %d: (%d) %s %x,%x %x,%x\n",
184 arg
[0], arg
[1], arg
[2], arg
[3]);
185 printf("\t%x,%x != %x,%x (csr %x %x)\n",
186 fp_res
[0], fp_res
[1],
187 em_res
[0], em_res
[1],
188 fp_res
[2], em_res
[2]);
193 while ((c
= getchar()) != EOF
&& c
!= '\n')
198 trapsignal(p
, sig
, code
)
201 printf("line %d: signal(%d, %x)\n", lineno
, sig
, code
);