3 * Test rig for bits header
5 * (c) 2000 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU Library General Public License as
14 * published by the Free Software Foundation; either version 2 of the
15 * License, or (at your option) any later version.
17 * mLib is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU Library General Public License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib; if not, write to the Free
24 * Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
28 /*----- Header files ------------------------------------------------------*/
33 /*----- Main code ---------------------------------------------------------*/
42 static void test_##OP(const struct tvec_reg *in, struct tvec_reg *out, \
47 LOAD64_(x, in[RX].v.bytes.p); \
48 OP##64_(x, x, in[RN].v.u); \
49 tvec_allocbytes(&out[RZ].v, 8); \
50 STORE64_(out[RZ].v.bytes.p, x); \
54 static void test_##OP(const struct tvec_reg *in, struct tvec_reg *out, \
59 LOAD64_(x, in[RX].v.bytes.p); LOAD64_(y, in[RY].v.bytes.p); \
61 tvec_allocbytes(&out[RZ].v, 8); \
62 STORE64_(out[RZ].v.bytes.p, x); \
72 static const struct tvec_urange ur_eight = { 8, 8 };
73 static const struct tvec_urange ur_shift = { 0, 63 };
74 static const struct tvec_regdef shift_regs[] = {
75 { "x", RX, &tvty_bytes, 0, { &ur_eight } },
76 { "n", RN, &tvty_uint, 0, { &ur_shift } },
77 { "z", RZ, &tvty_bytes, 0, { &ur_eight } },
80 static const struct tvec_regdef arith_regs[] = {
81 { "x", RX, &tvty_bytes, 0, { &ur_eight } },
82 { "y", RY, &tvty_bytes, 0, { &ur_eight } },
83 { "z", RZ, &tvty_bytes, 0, { &ur_eight } },
87 static const struct tvec_test tests[] = {
88 { "lsl64", shift_regs, 0, test_LSL },
89 { "lsr64", shift_regs, 0, test_LSR },
90 { "rol64", shift_regs, 0, test_ROL },
91 { "ror64", shift_regs, 0, test_ROR },
92 { "add64", arith_regs, 0, test_ADD },
93 { "sub64", arith_regs, 0, test_SUB },
97 static const struct tvec_config testconfig =
98 { tests, NROUT, NREG, sizeof(struct tvec_reg) };
100 int main(int argc, char *argv[])
101 { return (tvec_main(argc, argv, &testconfig, 0)); }
103 /*----- That's all, folks -------------------------------------------------*/