8800-simulator/index.html

129 lines
4.1 KiB
HTML
Raw Normal View History

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<style>
body {
margin: 30px;
font-family: monospace;
}
</style>
</head>
<body>
<h2>Text-mode Altair 8800 simulator</h2>
<hr>
<p>
<input type="button" value="INIT" onclick="init();">
<input type="button" value="TEST" onclick="test();">
<input type="button" value="RUN" onclick="run();">
<input type="button" value="STOP" onclick="stop();">
</p>
<hr>
<p>LEDs: <!-- &#x25cf; - on. &#x25cb; - off. -->
<div id="data-leds">
<p>
D7&nbsp;D6&nbsp;D5&nbsp;D4&nbsp;D3&nbsp;D2&nbsp;D1&nbsp;D0<br>
<span id="d7" class="led">&#x25cb;</span>&nbsp;
<span id="d6" class="led">&#x25cb;</span>&nbsp;
<span id="d5" class="led">&#x25cb;</span>&nbsp;
<span id="d4" class="led">&#x25cb;</span>&nbsp;
<span id="d3" class="led">&#x25cb;</span>&nbsp;
<span id="d2" class="led">&#x25cb;</span>&nbsp;
<span id="d1" class="led">&#x25cb;</span>&nbsp;
<span id="d0" class="led">&#x25cb;</span>&nbsp;
</p>
</div>
<div id="address-leds">
<p>
A15&nbsp;A14&nbsp;A13&nbsp;A12&nbsp;A11&nbsp;A10&nbsp;A9&nbsp;&nbsp;A8&nbsp;&nbsp;A7&nbsp;&nbsp;A6&nbsp;&nbsp;A5&nbsp;&nbsp;A4&nbsp;&nbsp;A3&nbsp;&nbsp;A2&nbsp;&nbsp;A1&nbsp;&nbsp;A0<br>
<span id="a15" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a14" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a13" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a12" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a11" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a10" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a9" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a8" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a7" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a6" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a5" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a4" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a3" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a2" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a1" class="led">&#x25cb;</span>&nbsp;&nbsp;
<span id="a0" class="led">&#x25cb;</span>&nbsp;&nbsp;
</p>
</div>
</p>
<hr>
<p>CPU dump:
<div id="cpu"></div>
</p>
<hr>
<p>Memory dump:
<div id="mem"></div>
</p>
<script src="js/8080.js"></script>
<script src="js/sim8800.js"></script>
<script>
2020-03-06 10:20:38 -05:00
function setAddressLedsCallback(bits) {
for (let i = 0; i < bits.length; i++) {
var ledElem = document.getElementById('a' + i);
ledElem.innerHTML = bits[i] ? '&#x25cf' : '&#x25cb';
}
}
function setDataLedsCallback(bits) {
for (let i = 0; i < bits.length; i++) {
var ledElem = document.getElementById('d' + i);
ledElem.innerHTML = bits[i] ? '&#x25cf' : '&#x25cb';
}
}
var dumpCpuElem = document.getElementById('cpu');
var dumpMemElem = document.getElementById('mem');
var sim = new Sim8800(256, 1000000,
2020-03-06 10:20:38 -05:00
setAddressLedsCallback, setDataLedsCallback,
dumpCpuElem, dumpMemElem);
function init() {
2020-03-06 10:20:38 -05:00
sim.loadDataAsHexString(0, '00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f');
sim.loadData(16, [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]);
sim.dumpCpu();
sim.dumpMem()
}
function test() {
console.log(Sim8800.parseBits(10, 1));
console.log(Sim8800.parseBits(0xF8, 1));
console.log(Sim8800.parseBits(0xF0, 2));
}
function run() {
2020-03-06 10:20:38 -05:00
// Switch echo between A2 and A1.
// sim.loadDataAsHexString(0, 'db ff d3 ff c3 00 00');
// Pattern shift.
sim.loadDataAsHexString(0, '3e 8c d3 ff 0f c3 02 00');
sim.start();
sim.dumpCpu();
sim.dumpMem()
}
function stop() {
sim.stop();
sim.dumpCpu();
sim.dumpMem()
}
</script>
</body>
</html>