-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
65 lines (57 loc) · 1.65 KB
/
main.cpp
File metadata and controls
65 lines (57 loc) · 1.65 KB
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
#include <iostream>
#include <iomanip>
#include <map>
using namespace std;
#include "globals.h"
#include "memoria.cpp"
#include "riscv.cpp"
int main (int argc, const char * argv[]) {
int n, opcao;
char c = 1;
init(); // inicia parametros globais
load_mem("text.bin", 0);
load_mem("data.bin", 0x2000);
cout << "Qual opção deseja executar:\n"
<< "1-verificar instruções\n"
<< "2-rodar passo a passo (aperte enter para ir para o passo seguinte)\n"
<< "3-rodar programa até o final\n";
cin >> opcao;
switch(opcao){
case 1:
cout << "Numero de instrucoes a imprimir: ";
cin >> n;
for (int i=0; i < n; i++) {
fetch();
decode();
cout << "Instr = " << instr_str[instruction]
<< " Imm = " << imm32_t
<< " rs1 = " << rs1
<< " rs2 = " << rs2
<< " rd = " << rd
<< endl;
}
break;
case 2:
while((pc < DATA_SEGMENT_START) && !stop_prg){
scanf("%c", &c);
while(c != '\n');
step();
dump_breg();
cout << "pc = " << pc << "\n";
c = 0;
}
break;
case 3:
run();
cout << "Deseja verificar o banco de registradores?\n1-sim\n2-não\n";
cin >> opcao;
if(opcao == 1){
dump_breg();
}
break;
default:
cout << "Opção inválida\n";
break;
}
return 0;
}