2 #error "N must be #defined"
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)
20 do_op_N (const alu_test
*tst
)
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)
34 else if (strcmp (op
->op
, "sub") == 0
35 || strcmp (op
->op
, "SUB") == 0)
39 printf (" -- operator unknown\n");
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
);
51 if (tst
->overflow
!= HAD_OVERFLOW
)
53 printf (" -- overflow wrong %d", HAD_OVERFLOW
);
56 if ((unsignedN
) CARRY_RESULT
!= (unsignedN
) tst
->result
)
58 printf (" -- carry result wrong ");
59 print_hex (CARRY_RESULT
, N
);
62 if ((unsignedN
) OVERFLOW_RESULT
!= (unsignedN
) tst
->result
)
64 printf (" -- overflow result wrong ");
65 print_hex (OVERFLOW_RESULT
, N
);
68 if ((unsignedN
) RESULT
!= (unsignedN
) tst
->result
)
70 printf (" -- result wrong ");
71 print_hex (RESULT
, N
);
83 #undef OVERFLOW_RESULT