-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTest.cpp
44 lines (36 loc) · 810 Bytes
/
Test.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
#include <assert.h>
#include <vector>
#include <string>
#include <iostream>
#include "CPU.h"
#include "asm.hpp"
using std::vector;
//
// This file contains tests for all instructions
//
int main()
{
CPU cpu;
cpu.init();
//test assembler
assert(assemble(mkop("ADD", "", 0, 50)) == 0b101100000000110010);
assert(assemble(mkop("ADD", "IZ", 0, 30)) == 0b101111000000011110);
vector<Operation> va = {
mkop("ADD", "", 0, 50),
mkop("ADD", "", 0, 30),
mkop("DAM", "", 0, 9),
mkop("LDR", "", 1, 9)
};
auto vr = assemble(va);
loadProgIntoMem(vr, &cpu);
cpu.cycle();
cpu.cycle();
cpu.cycle();
cpu.cycle();
cpu.cycle();
cpu.cycle();
cpu.printCPU();
cpu.dumpMem(0, 10);
std::cout << "Tests finished succesfully!\n";
return(0);
}