Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
96 lines (79 sloc) 2.61 KB
<!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">&nbsp;</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>