65816.js/index.html
2011-07-18 20:44:55 -04:00

134 lines
4.1 KiB
HTML

<html>
<script src="cpu.js">
</script>
<script src="lib/jquery-1.6.2.min.js">
</script>
<script>
var cpu;
$(document).ready(function() {
cpu = new CPU_65816();
updateFields();
var can_step = false;
$("#execute").click(function() {
cpu.reset();
cpu.execute($("#hex").val());
$("#load").removeAttr("disabled");
updateFields();
});
$("#reset").click(function() {
cpu.reset();
$("#hex").val("");
updateFields();
$("#step").attr("disabled", "disabled");
$("#load").removeAttr("disabled");
});
$("#load").click(function() {
cpu.reset();
cpu.load_program($("#hex").val());
updateFields();
can_step = true;
$("#step").removeAttr("disabled");
$("#load").attr("disabled", "disabled");
});
$("#step").click(function() {
if(can_step) {
cpu.executing = true;
cpu.step();
if(!cpu.executing) {
can_step = false;
$("#step").attr("disabled", "disabled");
$("#load").removeAttr("disabled");
}
updateFields();
}
});
});
function updateFields() {
$("#registerA").text(cpu.r.a.toString(16));
$("#registerB").text(cpu.r.b.toString(16));
$("#registerX").text(cpu.r.x.toString(16));
$("#registerY").text(cpu.r.y.toString(16));
$("#registerD").text(cpu.r.d.toString(16));
$("#registerS").text(cpu.r.s.toString(16));
$("#registerPC").text(cpu.r.pc.toString(16));
$("#registerDBR").text(cpu.r.dbr.toString(16));
$("#registerK").text(cpu.r.k.toString(16));
$("#registerPFlagE").text(cpu.p.e);
$("#registerPFlagC").text(cpu.p.c);
$("#registerPFlagZ").text(cpu.p.z);
$("#registerPFlagI").text(cpu.p.i);
$("#registerPFlagD").text(cpu.p.d);
$("#registerPFlagX").text(cpu.p.x);
$("#registerPFlagM").text(cpu.p.m);
$("#registerPFlagV").text(cpu.p.v);
$("#registerPFlagN").text(cpu.p.n);
}
</script>
<style>
.row {
width:100%;
float:left;
}
.label {
float:left;
width:40px;
}
.value {
float:left;
}
.left {
float:left;
width:50%;
}
.right {
float:left;
width:50%;
}
#hex {
height:140px;
width:400px;
}
</style>
<body>
<div class="left">
<div class="left">
<h3>Registers</h3>
<div class="row"><div class="label">a</div><div id="registerA" class="value"></div></div>
<div class="row"><div class="label">b</div><div id="registerB" class="value"></div></div>
<div class="row"><div class="label">x</div><div id="registerX" class="value"></div></div>
<div class="row"><div class="label">y</div><div id="registerY" class="value"></div></div>
<div class="row"><div class="label">d</div><div id="registerD" class="value"></div></div>
<div class="row"><div class="label">s</div><div id="registerS" class="value"></div></div>
<div class="row"><div class="label">pc</div><div id="registerPC" class="value"></div></div>
<div class="row"><div class="label">dbr</div><div id="registerDBR" class="value"></div></div>
<div class="row"><div class="label">k</div><div id="registerK" class="value"></div></div>
</div>
<div class="right">
<h3>P Register Flags</h3>
<div class="row"><div class="label">e</div><div id="registerPFlagE" class="value"></div></div>
<div class="row"><div class="label">c</div><div id="registerPFlagC" class="value"></div></div>
<div class="row"><div class="label">z</div><div id="registerPFlagZ" class="value"></div></div>
<div class="row"><div class="label">i</div><div id="registerPFlagI" class="value"></div></div>
<div class="row"><div class="label">d</div><div id="registerPFlagD" class="value"></div></div>
<div class="row"><div class="label">x</div><div id="registerPFlagX" class="value"></div></div>
<div class="row"><div class="label">m</div><div id="registerPFlagM" class="value"></div></div>
<div class="row"><div class="label">v</div><div id="registerPFlagV" class="value"></div></div>
<div class="row"><div class="label">n</div><div id="registerPFlagN" class="value"></div></div>
</div>
</div>
<div class="right">
<h3>Enter your program in hex here:</h3>
<textarea id="hex"></textarea>
<br/>
<button id="execute">Execute</button>
<button id="reset">Reset</button>
<button id="load">Load</button>
<button id="step" disabled="disabled">Step</button>
<!--
<button id="stop">Stop</button>
-->
</div>
</body>
</html>