-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram.js
More file actions
63 lines (46 loc) · 1.2 KB
/
Copy pathprogram.js
File metadata and controls
63 lines (46 loc) · 1.2 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
// program.js
/*
TODO:
*/
var Program = {
counter: 0x00400000,
// Create object to contain instructions.
instructions: {},
// Create object to contain labels.
labels: {},
add_instruction: function(instruction) {
this.instructions[this.counter] = instruction;
this.counter += 4;
},
add_label: function(label) {
this.labels[label] = this.counter;
},
enter_loop: function() {
this.counter = 0x00400000;
this.execution_interval = setInterval(function() {
Program.execute();
}, 80);
},
execute: function() {
if(Program.instructions[Program.counter] != undefined) {
Instructions[Program.instructions[Program.counter].instruction].operation(Program.instructions[Program.counter].arguments);
Program.counter += 4;
Registers.PC.set_value(Program.counter);
}
},
exit: function() {
clearInterval(this.execution_interval);
},
pause: function() {
clearInterval(this.execution_interval);
},
reinitialize: function() {
this.counter = 0x00400000;
this.instructions = {};
},
step: function() {
// Stop execution interval if execution is underway
clearInterval(this.execution_interval);
this.execute();
}
};