-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjz.cpp
More file actions
59 lines (48 loc) · 1022 Bytes
/
jz.cpp
File metadata and controls
59 lines (48 loc) · 1022 Bytes
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
/*#include<bits/stdc++.h>
using namespace std;
struct elements {
string pc;
string start;
string registers[7];
map<string, string> memory;
int flags[8];
};*/
#include "headers.h"
#include "methods.h"
int jz(elements *e) {
map<string, string> :: iterator it = e->memory.begin();
string inst = e->memory[e->pc];
string address = "", instAdd = e->pc;
int i;
int p = inst.find(' ');
for(i = p+1;i<inst.length();i++) {
address += inst[i];
}
cout << address << endl;
if(e->flags[6] == 1) {
e->pc = address;
}
else {
updatePc(e);
// while(it->first != instAdd) {
// it++;
// }
// it++;
// e->pc = it->first;
}
return 1;
}
/*int main() {
elements e;
e.memory["2000"] = "MOV A,B";
e.memory["2001"] = "LDA 2050";
e.memory["2004"] = "JMP 2001";
e.memory["2007"] = "HLT";
e.pc = "2004";
e.flags[1] = 0;
if(jz(&e))
cout << e.pc << " " << e.memory[e.pc] << endl;
else
cout << "Invalid address" << endl;
return 0;
}*/