-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
i8080_tests.cpp
89 lines (70 loc) · 2.49 KB
/
i8080_tests.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
// the intel 8080 code is unstable, if there are bugs send an insue :)
// the code is constantly being updated, i'm planning to bring new features
// to the intel 8080, an example would be an overflow flag...
// if you wanted to send a pull stay a I will analyze them all
#include "../i8080.hpp"
#include "../disassembly.hpp"
#include <time.h>
#define DISASSEMBLY false
static void banner()
{
std::cout << " ____________________________ " << std::endl;
std::cout << " / /\\ " << std::endl;
std::cout << " / Vitor Mob _/ /\\ " << std::endl;
std::cout << " / Intel8080 / \\ " << std::endl;
std::cout << " / /\\ " << std::endl;
std::cout << " /___________________________/ / " << std::endl;
std::cout << " \\___________________________\\/ " << std::endl;
std::cout << " \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ \\ " << std::endl
<< std::endl;
}
const static void execute_tests(const std::string &name)
{
i8080 cpu;
Disassembly disass;
byte_t *mem = cpu.memory_addr(); // memory
// registers
word_t PC;
word_t DE;
byte_t E;
byte_t C;
cpu.load_file_bin(name, mem, 0x100); // load bin for memory and jump pc for 0x100
int instructions = 0; // counter instructions
mem[0x00005] = 0xc9;
while (true)
{
PC = cpu.get_pc();
E = cpu.get_register_e();
C = cpu.get_register_c();
DE = cpu.get_register_de();
if (PC == 5)
{
if (C == 2)
std::cout.put(E);
else if (C == 9)
for (int i = DE; mem[i] != 0x24; i++)
std::cout.put(mem[i]);
}
instructions++;
cpu.i8080_instructions();
if (DISASSEMBLY == true)
{
disass.run_disassembly(PC, mem);
disass.run_memory(mem, cpu.get_size_mem());
}
if (PC == 0 || mem[PC] == 0x76)
break;
}
std::cout << "\n\n*** Cycles=" << std::dec << cpu.get_cycles() << std::endl
<< "*** Instructions=" << instructions << std::endl;
}
int main()
{
banner();
clock_t start = clock();
execute_tests("src/intel8080/i8080_tests/bin/TST8080.COM");
execute_tests("src/intel8080/i8080_tests/bin/8080PRE.COM");
clock_t result = clock() - start;
std::cout << "\n*** Runtime=" << result << " ms" << std::endl;
return EXIT_SUCCESS;
}