2020-03-05 23:36:30 -05:00
|
|
|
<!doctype html>
|
|
|
|
<html>
|
|
|
|
<head>
|
2020-03-06 09:15:26 -05:00
|
|
|
<meta charset="utf-8">
|
|
|
|
<style>
|
|
|
|
body {
|
|
|
|
margin: 30px;
|
|
|
|
font-family: monospace;
|
|
|
|
}
|
|
|
|
</style>
|
2020-03-05 23:36:30 -05:00
|
|
|
</head>
|
2020-03-06 09:15:26 -05:00
|
|
|
<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: <!-- ● - on. ○ - off. -->
|
|
|
|
<div id="data-leds">
|
|
|
|
<p>
|
|
|
|
D7 D6 D5 D4 D3 D2 D1 D0<br>
|
|
|
|
<span id="d7" class="led">○</span>
|
|
|
|
<span id="d6" class="led">○</span>
|
|
|
|
<span id="d5" class="led">○</span>
|
|
|
|
<span id="d4" class="led">○</span>
|
|
|
|
<span id="d3" class="led">○</span>
|
|
|
|
<span id="d2" class="led">○</span>
|
|
|
|
<span id="d1" class="led">○</span>
|
|
|
|
<span id="d0" class="led">○</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
<div id="address-leds">
|
|
|
|
<p>
|
|
|
|
A15 A14 A13 A12 A11 A10 A9 A8 A7 A6 A5 A4 A3 A2 A1 A0<br>
|
|
|
|
<span id="a15" class="led">○</span>
|
|
|
|
<span id="a14" class="led">○</span>
|
|
|
|
<span id="a13" class="led">○</span>
|
|
|
|
<span id="a12" class="led">○</span>
|
|
|
|
<span id="a11" class="led">○</span>
|
|
|
|
<span id="a10" class="led">○</span>
|
|
|
|
<span id="a9" class="led">○</span>
|
|
|
|
<span id="a8" class="led">○</span>
|
|
|
|
<span id="a7" class="led">○</span>
|
|
|
|
<span id="a6" class="led">○</span>
|
|
|
|
<span id="a5" class="led">○</span>
|
|
|
|
<span id="a4" class="led">○</span>
|
|
|
|
<span id="a3" class="led">○</span>
|
|
|
|
<span id="a2" class="led">○</span>
|
|
|
|
<span id="a1" class="led">○</span>
|
|
|
|
<span id="a0" class="led">○</span>
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<hr>
|
|
|
|
|
|
|
|
<p>CPU dump:
|
|
|
|
<div id="cpu"></div>
|
|
|
|
</p>
|
2020-03-05 23:36:30 -05:00
|
|
|
|
2020-03-06 09:15:26 -05:00
|
|
|
<hr>
|
2020-03-06 00:06:47 -05:00
|
|
|
|
2020-03-06 09:15:26 -05:00
|
|
|
<p>Memory dump:
|
|
|
|
<div id="mem"></div>
|
|
|
|
</p>
|
2020-03-05 23:36:30 -05:00
|
|
|
|
|
|
|
<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] ? '●' : '○';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
function setDataLedsCallback(bits) {
|
|
|
|
for (let i = 0; i < bits.length; i++) {
|
|
|
|
var ledElem = document.getElementById('d' + i);
|
|
|
|
ledElem.innerHTML = bits[i] ? '●' : '○';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-03-06 09:15:26 -05:00
|
|
|
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,
|
2020-03-06 09:15:26 -05:00
|
|
|
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');
|
2020-03-06 09:15:26 -05:00
|
|
|
sim.loadData(16, [0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07]);
|
|
|
|
sim.dumpCpu();
|
|
|
|
sim.dumpMem()
|
|
|
|
}
|
|
|
|
|
2020-03-05 23:36:30 -05:00
|
|
|
function test() {
|
2020-03-06 09:15:26 -05:00
|
|
|
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');
|
2020-03-06 09:15:26 -05:00
|
|
|
sim.start();
|
|
|
|
sim.dumpCpu();
|
|
|
|
sim.dumpMem()
|
|
|
|
}
|
|
|
|
|
|
|
|
function stop() {
|
|
|
|
sim.stop();
|
|
|
|
sim.dumpCpu();
|
|
|
|
sim.dumpMem()
|
2020-03-05 23:36:30 -05:00
|
|
|
}
|
|
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|