* "objcopy -O binary" warning tweak, suggested by dmoseley
[binutils-gdb.git] / sim / testsuite / common / alu-n-tst.h
blobbf2635f08fe2f390149339dcea9f51f7891348b6
1 #ifndef N
2 #error "N must be #defined"
3 #endif
5 #include "sim-xcat.h"
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)
19 void
20 do_op_N (const alu_test *tst)
22 const alu_op *op;
23 /* without type cast */
25 OP_BEGIN (tst->begin);
26 print_hex (tst->begin, N);
27 for (op = tst->ops; op->op != NULL; op++)
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
39 printf (" -- operator unknown\n");
40 abort ();
43 printf (" = ");
44 print_hex (tst->result, N);
45 printf (" C%d V%d", tst->carry, tst->overflow);
46 if (tst->carry != HAD_CARRY)
48 printf (" -- carry wrong %d", HAD_CARRY);
49 errors ++;
51 if (tst->overflow != HAD_OVERFLOW)
53 printf (" -- overflow wrong %d", HAD_OVERFLOW);
54 errors ++;
56 if ((unsignedN) CARRY_RESULT != (unsignedN) tst->result)
58 printf (" -- carry result wrong ");
59 print_hex (CARRY_RESULT, N);
60 errors ++;
62 if ((unsignedN) OVERFLOW_RESULT != (unsignedN) tst->result)
64 printf (" -- overflow result wrong ");
65 print_hex (OVERFLOW_RESULT, N);
66 errors ++;
68 if ((unsignedN) RESULT != (unsignedN) tst->result)
70 printf (" -- result wrong ");
71 print_hex (RESULT, N);
72 errors ++;
74 printf ("\n");
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