-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmmix-wasm.html
83 lines (80 loc) · 3.63 KB
/
mmix-wasm.html
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
<!doctype html>
<html lang="en-us">
<head>
<meta charset="utf-8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>MMIX-WASM</title>
<link rel="stylesheet" href="mmix-wasm.css" />
<meta name="viewport" content="width=device-width,initial-scale=1.0">
</head>
<body>
<div id="io-container">
<div id="toolbar">
<span id="status">No Javascript</span>
<span id="instruction-count-container">Instruction <span id="instruction-count">0</span></span>
<span id="freq-container">Freq<input id="freq" type="text" value="2"></input>Hz</span>
<progress id="progress">Not Loaded</progress>
<span id="g_reg-container">Register<input id="g_reg_num" type="text" value="255"></input><span id="g_reg_val"></span></span>
</div>
<div id="input_c"><p>Input</p><textarea id="input"></textarea></div>
<div id="error_c"><p>Error</p><textarea id="error"></textarea></div>
<div id="output_c"><p>Output</p><textarea id="output"></textarea></div>
</div>
<script type="text/javascript" >
var progressElement = document.getElementById('progress');
var statusElement = document.getElementById('status');
var Module = {
preRun: [],
postRun: [],
print: function(text){
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.log(text);
},
printErr: function(text){
if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
console.error(text);
},
setStatus: function(text) {
if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
if (text === Module.setStatus.last.text) return;
var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
var now = Date.now();
if (m && now - Module.setStatus.last.time < 20) return; // if this is a progress update, skip it if too soon
Module.setStatus.last.time = now;
Module.setStatus.last.text = text;
if (m) {
text = m[1];
progressElement.value = parseInt(m[2])*100;
progressElement.max = parseInt(m[4])*100;
progressElement.hidden = false;
} else {
progressElement.hidden = true;
}
if (text == '') {
statusElement.style.display = "none";
statusElement.innerHTML = text;
} else {
statusElement.style.display = "";
statusElement.innerHTML = text;
}
},
totalDependencies: 0,
monitorRunDependencies: function(left) {
this.totalDependencies = Math.max(this.totalDependencies, left);
Module.setStatus(left ? 'Loading WASM... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
}
};
Module.setStatus('Downloading...');
window.onerror = function(event) {
// TODO: do not warn on ok events like simulating an infinite loop or exitStatus
Module.setStatus('Exception thrown, see JavaScript console');
Module.setStatus = function(text) {
if (text) Module.printErr('[post-exception status] ' + text);
};
};
</script>
<script defer type="text/javascript" src="jquery.js"></script>
<script defer type="text/javascript" src="mmix-wasm-page.js"></script>
<script defer type="text/javascript" src="mmix.js"></script>
</body>
</html>