Repository navigation
Expand file tree
/
Copy pathrepl.html
More file actions
95 lines (79 loc) · 2.61 KB
/
Copy pathrepl.html
File metadata and controls
95 lines (79 loc) · 2.61 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<!doctype html>
<html>
<head>
<title>yasp repl</title>
<meta charset="utf-8">
<style type="text/css">
.row > .col {
display: inline-block;
vertical-align: top;
margin-left: 15px;
padding-right: 15px;
min-width: 200px;
border-right: solid black 5px;
}
</style>
<script src="../lib/js/jquery-1.10.2.min.js"></script>
<script src="../app/js/commands.js"></script>
<script src="../app/js/utils.js"></script>
</head>
<body>
<script src="../app/js/assembler/assembler.js"></script>
<script src="../app/js/assembler/passes/lexer.js"></script>
<script src="../app/js/assembler/passes/analyser.js"></script>
<script src="../app/js/assembler/passes/parser.js"></script>
<script src="../app/js/assembler/passes/generator.js"></script>
<script src="../app/js/emulator/bitutils.js"></script>
<script src="../app/js/emulator/disasm.js"></script>
<script src="../app/js/emulator/emulator.js"></script>
<script src="./repl.js"></script>
Input: <input id="code" value="MOV b0,b1"><br>
<button id="benchmark">Benchmark</button> => <span id="timeTakenHz">0 Hz</span><br><br>
<pre id="bitcode"> </pre><br>
<div class="row">
<pre id="regs" class="col"></pre>
<pre id="pins" class="col"></pre>
</div>
<script type="text/javascript">
var repl = new yasp.Repl();
dumpRam();
$('#code').bind('keypress', function(e) {
if(e.keyCode==13){
var result = repl.execute(getCode());
dumpRam();
if(result.bitcode)
$('#bitcode').text("Bitcode: " + yasp.Repl.getDumpFromArray(result.bitcode, -1));
if(result.error !== null) {
var error = getPrettyAsmError(result.error.errors);
$('#bitcode').text(error);
}
clearCode();
}
});
$('#benchmark').click(function (e) {
$('#timeTakenHz').text("working..");
setTimeout(function () {
var result = repl.benchmark(getCode(), 5000000);
$('#timeTakenHz').text(Math.round(result.hz * 10) / 10 + " Hz");
}, 0)
});
function getPrettyAsmError (errors) {
var error = "";
for (var i = 0; i < errors.length; i++) {
error += errors[i].message.replace('\n', '↵');
}
return error;
}
function getCode () {
return $('#code').val();
}
function clearCode () {
$('#code').val("");
}
function dumpRam () {
$('#regs').text(repl.getRegisterDump());
$('#pins').text("Pins:\n\n" + repl.getPinDump());
}
</script>
</body>
</html>