|
|
1.1 ! root 1: // ! 2: // nono ! 3: // Copyright (C) 2023 nono project ! 4: // Licensed under nono-license.txt ! 5: // ! 6: ! 7: // ! 8: // テストコード生成の共通サブルーチン ! 9: // ! 10: ! 11: #include "optestxp_subr.h" ! 12: #include "mystring.h" ! 13: ! 14: const char *testname; ! 15: int testpos; ! 16: std::vector<std::string> testlist; ! 17: ! 18: // gentest の最初で行うことまとめ。 ! 19: void ! 20: init(const char *testname_, const char *method) ! 21: { ! 22: testname = testname_; ! 23: testlist.push_back(testname); ! 24: ! 25: out("test_%s:\n", testname); ! 26: out(" LD HL,testset_%s\n", testname); ! 27: out(" JP %s\n", method); ! 28: ! 29: testpos = 0; ! 30: } ! 31: ! 32: // テストセットのテーブルを出力。 ! 33: void ! 34: out_testset() ! 35: { ! 36: out("testset_%s:\n", testname); ! 37: out(" defw testname_%s\n", testname); ! 38: out(" defw testexec_%s\n", testname); ! 39: out(" defw testdata_%s\n", testname); ! 40: out(" defb %d\n", (strcmp(testname, "daa") == 0) ? 1 : 0); ! 41: ! 42: out("testname_%s:\n", testname); ! 43: std::string upper = string_toupper(testname); ! 44: out(" defm \"%s $\"\n", upper.c_str()); ! 45: out("\n"); ! 46: } ! 47: ! 48: // testrun1 テスト用のデータテーブルを出力。 ! 49: void ! 50: out_testdata_run1(uint32 dst, const hd64180flag& inflag, ! 51: uint32 res, const hd64180flag& flag) ! 52: { ! 53: if (testpos == 0) { ! 54: out("testdata_%s:\n", testname); ! 55: } ! 56: out(" defb 0%02xH,0%02xH,0%02xH,0%02xH ; %s_%02x\n", ! 57: dst, inflag.Get(), res, flag.Get(), testname, testpos); ! 58: testpos++; ! 59: } ! 60: ! 61: // testrun2 テスト用のデータテーブルを出力。 ! 62: void ! 63: out_testdata_run2(uint32 dst, const hd64180flag& inflag, uint32 src, ! 64: uint32 res, const hd64180flag& flag) ! 65: { ! 66: if (testpos == 0) { ! 67: out("testdata_%s:\n", testname); ! 68: } ! 69: out(" defb 0%02xH,0%02xH,0%02xH,0%02xH,0%02xH ; %s_%02x\n", ! 70: dst, inflag.Get(), src, res, flag.Get(), testname, testpos); ! 71: testpos++; ! 72: } ! 73: ! 74: void ! 75: out(const char *fmt, ...) ! 76: { ! 77: va_list ap; ! 78: ! 79: va_start(ap, fmt); ! 80: vprintf(fmt, ap); ! 81: va_end(ap); ! 82: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.