|
|
1.1 root 1: //
2: // nono
3: // Copyright (C) 2023 nono project
4: // Licensed under nono-license.txt
5: //
6:
7: //
8: // DAA のテスト
9: //
10:
11: #include "optestxp_subr.h"
12:
13: static void
14: gentest_daa()
15: {
16: init("daa", "testrun1");
17:
18: out("testexec_%s:\n", testname);
19: out(" DAA\n");
20: out(" RET\n");
21:
22: out_testset();
23:
24: for (int nin = 0; nin <= 1; nin++) {
25: for (uint32 dst = 0; dst < 0x100; dst++) {
26: for (int hin = 0; hin <= 1; hin++) {
27: for (int cin = 0; cin <= 1; cin++) {
28: uint32 ah = dst >> 4;
29: uint32 al = dst & 0x0f;
30: uint32 add = 0;
31: bool c = false;
32:
33: if (nin == 0) {
34: if (cin == 0) {
35: if (hin == 0) {
36: if (ah < 9) {
37: if (al < 10) {
38: } else {
39: add = 0x06;
40: }
41: } else if (ah == 9) {
42: if (al < 10) {
43: } else {
44: add = 0x66;
45: c = true;
46: }
47: } else {
48: if (al < 10) {
49: add = 0x60;
50: } else {
51: add = 0x66;
52: }
53: c = true;
54: }
55: } else { // H=1
56: if (ah < 9) {
57: add = 0x06;
58: } else if (ah == 9) {
59: if (1 || al < 10) { // HD64180?
60: add = 0x06;
61: } else {
62: add = 0x66;
63: c = true;
64: }
65: } else {
66: add = 0x66;
67: c = true;
68: }
69: }
70: } else { // C=1
71: if (hin == 0) {
72: if (al < 10) {
73: add = 0x60;
74: } else {
75: add = 0x66;
76: }
77: } else {
78: add = 0x66;
79: }
80: c = true;
81: }
82: } else { // N=1
83: if (cin == 0) {
84: if (hin == 0) {
85: } else { // H=1
86: add = 0x06;
87: if (dst < 6) {
88: c = true;
89: }
90: }
91: } else { // C=1
92: if (hin == 0) {
93: add = 0x60;
94: } else {
95: add = 0x66;
96: }
97: c = true;
98: }
99: }
100:
101: uint32 res32;
102: if (nin == 0) {
103: res32 = dst + add;
104: } else {
105: res32 = dst - add;
106: }
107: uint8 res = res32;
108:
109: hd64180flag inflag;
110: inflag.N = nin;
111: inflag.H = hin;
112: inflag.C = cin;
113:
114: hd64180flag flag;
115: flag.Z = (res == 0);
116: flag.S = ((res & 0x80) != 0);
117: flag.C = c;
118: flag.PV = pflag(res);
119: flag.H = (nin == 0) ?
120: hflag_add(dst, add) : hflag_sub(dst, add);
121: flag.N = nin;
122: out_testdata_run1(dst, inflag, res, flag);
123: }
124: }
125: }
126: }
127: out(" defb 0,0,0,0FFH\n");
128: out("\n");
129: }
130:
131: int
132: main(int ac, char *av[])
133: {
134: out(" org 0100H\n");
135: gentest_daa();
136: out(" RET\n");
137:
138: return 0;
139: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.