-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstruction.cpp
More file actions
53 lines (46 loc) · 861 Bytes
/
instruction.cpp
File metadata and controls
53 lines (46 loc) · 861 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
#include "./headers/instruction.h"
instr_queue::instr_queue(vector<instr> a):
Q(a),size(a.size())
{
squash = false;
head = 0;
}
bool instr_queue::finished()
{
return head == size;
}
void instr_queue::move_ptr(int target)
{
head = target;
}
bool instr_queue::ptr_advance()
{
if (head >= size)
{
err_log("Instr queue acccess out of range while advancing");
return false;
}
head ++;
return true;
}
bool instr_queue::ptr_branch(int offset)
{
int dest = offset + head + 1;
if (dest >= size || dest < 0)
{
err_log("Instr queue acccess out of range while branching");
return false;
}
head = dest;
return true;
}
int instr_queue::get_head()
{
return head;
}
const instr* instr_queue::getInstr()
{
if (head == size)
return nullptr;
return &Q[head];
}