This commit was generated by cvs2svn to track changes on a CVS vendor
[deliverable/binutils-gdb.git] / sim / testsuite / common / alu-n-tst.h
1 #ifndef N
2 #error "N must be #defined"
3 #endif
4
5 #include "sim-xcat.h"
6
7 /* NOTE: see end of file for #undef of these macros */
8 #define unsignedN XCONCAT2(unsigned,N)
9 #define OP_BEGIN XCONCAT3(ALU,N,_BEGIN)
10 #define OP_ADD XCONCAT3(ALU,N,_ADD)
11 #define OP_SUB XCONCAT3(ALU,N,_SUB)
12 #define HAD_OVERFLOW (XCONCAT3(ALU,N,_HAD_OVERFLOW) != 0)
13 #define HAD_CARRY (XCONCAT3(ALU,N,_HAD_CARRY) != 0)
14 #define RESULT XCONCAT3(ALU,N,_RESULT)
15 #define OVERFLOW_RESULT XCONCAT3(ALU,N,_OVERFLOW_RESULT)
16 #define CARRY_RESULT XCONCAT3(ALU,N,_CARRY_RESULT)
17 #define do_op_N XCONCAT2(do_op_,N)
18
19 void
20 do_op_N (const alu_test *tst)
21 {
22 const alu_op *op;
23 /* without type cast */
24 {
25 OP_BEGIN (tst->begin);
26 print_hex (tst->begin, N);
27 for (op = tst->ops; op->op != NULL; op++)
28 {
29 printf (" %s ", op->op);
30 print_hex (op->arg, N);
31 if (strcmp (op->op, "add") == 0
32 || strcmp (op->op, "ADD") == 0)
33 OP_ADD (op->arg);
34 else if (strcmp (op->op, "sub") == 0
35 || strcmp (op->op, "SUB") == 0)
36 OP_SUB (op->arg);
37 else
38 {
39 printf (" -- operator unknown\n");
40 abort ();
41 }
42 }
43 printf (" = ");
44 print_hex (tst->result, N);
45 printf (" C%d V%d", tst->carry, tst->overflow);
46 if (tst->carry != HAD_CARRY)
47 {
48 printf (" -- carry wrong %d", HAD_CARRY);
49 errors ++;
50 }
51 if (tst->overflow != HAD_OVERFLOW)
52 {
53 printf (" -- overflow wrong %d", HAD_OVERFLOW);
54 errors ++;
55 }
56 if ((unsignedN) CARRY_RESULT != (unsignedN) tst->result)
57 {
58 printf (" -- carry result wrong ");
59 print_hex (CARRY_RESULT, N);
60 errors ++;
61 }
62 if ((unsignedN) OVERFLOW_RESULT != (unsignedN) tst->result)
63 {
64 printf (" -- overflow result wrong ");
65 print_hex (OVERFLOW_RESULT, N);
66 errors ++;
67 }
68 if ((unsignedN) RESULT != (unsignedN) tst->result)
69 {
70 printf (" -- result wrong ");
71 print_hex (RESULT, N);
72 errors ++;
73 }
74 printf ("\n");
75 }
76 }
77
78 #undef OP_BEGIN
79 #undef OP_ADD
80 #undef OP_SUB
81 #undef HAD_OVERFLOW
82 #undef HAD_CARRY
83 #undef OVERFLOW_RESULT
84 #undef CARRY_RESULT
85 #undef RESULT
86 #undef do_op_N
87 #undef unsignedN
This page took 0.0319 seconds and 4 git commands to generate.