examine and examineNext logic
This commit is contained in:
parent
6dc3f05734
commit
ae735688e6
20
index.html
20
index.html
|
@ -211,6 +211,17 @@ db ff d3 ff c3 00 00 // Switch echo between A2 and A1.
|
||||||
dumpMemElem.innerHTML = dumpHtml;
|
dumpMemElem.innerHTML = dumpHtml;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getInputWord() {
|
||||||
|
var word = 0;
|
||||||
|
for (let i = 0; i < 16; i++) {
|
||||||
|
var switchElem = document.getElementById('s' + i);
|
||||||
|
if (switchElem.checked) {
|
||||||
|
word |= 1 << i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return word;
|
||||||
|
}
|
||||||
|
|
||||||
var sim = new Sim8800(256, 1000000,
|
var sim = new Sim8800(256, 1000000,
|
||||||
setAddressLedsCallback, setDataLedsCallback,
|
setAddressLedsCallback, setDataLedsCallback,
|
||||||
setWaitLedCallback, setStatusLedsCallback,
|
setWaitLedCallback, setStatusLedsCallback,
|
||||||
|
@ -244,6 +255,15 @@ db ff d3 ff c3 00 00 // Switch echo between A2 and A1.
|
||||||
function stop() {
|
function stop() {
|
||||||
sim.stop();
|
sim.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function examine() {
|
||||||
|
var address = getInputWord();
|
||||||
|
sim.examine(address);
|
||||||
|
}
|
||||||
|
|
||||||
|
function examineNext() {
|
||||||
|
sim.examineNext();
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -51,6 +51,7 @@ class Sim8800 {
|
||||||
this.dumpMemCallback = dumpMemCallback;
|
this.dumpMemCallback = dumpMemCallback;
|
||||||
this.isPoweredOn = false;
|
this.isPoweredOn = false;
|
||||||
this.isRunning = false;
|
this.isRunning = false;
|
||||||
|
this.lastAddress = 0;
|
||||||
this.initMem();
|
this.initMem();
|
||||||
CPU8080.init(this.getWriteByteCallback(),
|
CPU8080.init(this.getWriteByteCallback(),
|
||||||
this.getReadByteCallback(),
|
this.getReadByteCallback(),
|
||||||
|
@ -313,6 +314,7 @@ class Sim8800 {
|
||||||
return;
|
return;
|
||||||
CPU8080.reset();
|
CPU8080.reset();
|
||||||
this.stop();
|
this.stop();
|
||||||
|
this.lastAddress = 0;
|
||||||
if (this.setAddressLedsCallback) {
|
if (this.setAddressLedsCallback) {
|
||||||
this.setAddressLedsCallback(new Array(16).fill(1));
|
this.setAddressLedsCallback(new Array(16).fill(1));
|
||||||
}
|
}
|
||||||
|
@ -368,9 +370,37 @@ class Sim8800 {
|
||||||
this.dumpCpu();
|
this.dumpCpu();
|
||||||
this.dumpMem();
|
this.dumpMem();
|
||||||
if (this.setAddressLedsCallback) {
|
if (this.setAddressLedsCallback) {
|
||||||
var cpu = CPU8080.status();
|
let cpu = CPU8080.status();
|
||||||
var pcBits = Sim8800.parseBits(cpu.pc, 16);
|
let bits = Sim8800.parseBits(cpu.pc, 16);
|
||||||
this.setAddressLedsCallback(pcBits);
|
this.setAddressLedsCallback(bits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a byte from the given address.
|
||||||
|
* @param {number} address The given address.
|
||||||
|
*/
|
||||||
|
examine(address) {
|
||||||
|
if (!this.isPoweredOn)
|
||||||
|
return;
|
||||||
|
this.lastAddress = address;
|
||||||
|
if (this.setAddressLedsCallback) {
|
||||||
|
let bits = Sim8800.parseBits(address, 16);
|
||||||
|
this.setAddressLedsCallback(bits);
|
||||||
|
}
|
||||||
|
if (this.setDataLedsCallback) {
|
||||||
|
let bits = Sim8800.parseBits(this.mem[address], 8);
|
||||||
|
this.setDataLedsCallback(bits);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a byte from the next address.
|
||||||
|
*/
|
||||||
|
examineNext() {
|
||||||
|
if (!this.isPoweredOn)
|
||||||
|
return;
|
||||||
|
this.lastAddress++;
|
||||||
|
this.examine(this.lastAddress);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue
Block a user