Added cycle count to interval runs
This commit is contained in:
parent
108b967a87
commit
44cdd9c219
@ -42,7 +42,8 @@
|
||||
<div>
|
||||
<input type="button" id ="btn_clk" value="CLOCK" />
|
||||
<span id="clk_counter">0</span><input type="button" id ="btn_runtil" value="BREAK AT:" /> 0x<input id="addrbrk" type="text" value="05" pattern="[a-fA-F\d]+" />
|
||||
<span>Clock Interval: </span><input id="clkinterval" type="text" value="1" />mS
|
||||
<span>Clock Interval: </span><input id="clkinterval" type="number" value="1" size="4" min="1" max="999999" />mS
|
||||
<span>Cycles Per Interval: </span><input id="clkcycles" type="number" value="1" size="4" min="1" max="999999" />
|
||||
</div>
|
||||
<div>
|
||||
<span>Text Output (0x8000-0x83ff):</span><br />
|
||||
|
31
js/cpu.js
31
js/cpu.js
@ -142,18 +142,24 @@ function generateClocks(clk_cnt) {
|
||||
}
|
||||
}
|
||||
|
||||
function generateClocks_Interval() {
|
||||
function generateClocks_Interval(cycles_per_run=1) {
|
||||
/* if (cpu._CLK) {
|
||||
cpu.CLOCK(false);
|
||||
} else {
|
||||
cpu.CLOCK(true);
|
||||
}*/
|
||||
cpu.CLOCK(true);
|
||||
clk_count++;
|
||||
clk_counter.innerText = clk_count;
|
||||
cpu.CLOCK(false);
|
||||
|
||||
if (cpu.ADDRBUS === breakpt) clearInterval(intval);
|
||||
for (let a = 0; a < cycles_per_run; a++) {
|
||||
cpu.CLOCK(true);
|
||||
clk_count++;
|
||||
clk_counter.innerText = clk_count;
|
||||
cpu.CLOCK(false);
|
||||
|
||||
if (cpu.ADDRBUS === breakpt) {
|
||||
clearInterval(intval);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function drawCPUInfo() {
|
||||
@ -161,10 +167,10 @@ function drawCPUInfo() {
|
||||
window.requestAnimationFrame(drawCPUInfo);
|
||||
}
|
||||
|
||||
function RunUntilBreak(addr) {
|
||||
function RunUntilBreak(addr,cycles = 1) {
|
||||
breakpt = addr;
|
||||
intval = setInterval(function(){
|
||||
generateClocks_Interval();
|
||||
generateClocks_Interval(cycles);
|
||||
}, parseInt(clkinterval.value));
|
||||
}
|
||||
|
||||
@ -176,13 +182,14 @@ function printTextOut(ram,startaddr,endaddr) {
|
||||
}
|
||||
}
|
||||
|
||||
function printRAM(ram) {
|
||||
let startADDR = (cpu.ADDRBUS & 0xfff0) - 0x80;
|
||||
function printRAM(ram,lines = 4) {
|
||||
let addrSpan = lines;
|
||||
let startADDR = (cpu.ADDRBUS & 0xfff0) - ((addrSpan*16)/2);
|
||||
if (startADDR < 0) startADDR = 0;
|
||||
if (startADDR > 0xFEFF) startADDR = 0xFF00;
|
||||
if (startADDR > 0xFEFF) startADDR = (0xFF00 + (addrSpan*16));
|
||||
let sp_ram = document.getElementById("RAM");
|
||||
let ramtext = "ADDR : 0 1 2 3 4 5 6 7 8 9 A B C D E F<br />";
|
||||
for (let a = startADDR; a < (startADDR+255); a+=16) {
|
||||
for (let a = startADDR; a < (startADDR+(addrSpan*16)); a+=16) {
|
||||
ramtext += "0x" + formatHex(a,4) + ": ";
|
||||
for (let b = 0; b < 16; b++) {
|
||||
if (cpu.ADDRBUS === (a)+b) {
|
||||
|
88
js/main.js
88
js/main.js
@ -1,88 +1,6 @@
|
||||
let cpu = new CPU_8SA1();
|
||||
GenerateMicrocode(Instructions,cpu);
|
||||
|
||||
/*cpu.RAM[0] = is_LDA_i.Bytecode;
|
||||
cpu.RAM[1] = 0;
|
||||
cpu.RAM[2] = is_LDB_i.Bytecode;
|
||||
cpu.RAM[3] = 100;
|
||||
cpu.RAM[4] = is_ADD.Bytecode;
|
||||
cpu.RAM[5] = is_BCC_i.Bytecode;
|
||||
cpu.RAM[6] = 4;
|
||||
cpu.RAM[7] = is_LDD_i.Bytecode;
|
||||
cpu.RAM[8] = 69;
|
||||
cpu.RAM[9] = is_STDL_i.Bytecode;
|
||||
cpu.RAM[10] = 0x69;
|
||||
cpu.RAM[11] = is_PHD.Bytecode;
|
||||
cpu.RAM[12] = is_PLC.Bytecode;
|
||||
*/
|
||||
/*cpu.RAM[0] = is_JSR.Bytecode;
|
||||
cpu.RAM[1] = 0x40;
|
||||
cpu.RAM[2] = is_LDA_i.Bytecode;
|
||||
cpu.RAM[3] = 0x20;
|
||||
cpu.RAM[4] = is_PLB.Bytecode;
|
||||
cpu.RAM[5] = is_ADD.Bytecode;
|
||||
cpu.RAM[0x40] = is_PLAB.Bytecode;
|
||||
cpu.RAM[0x41] = is_LDC_i.Bytecode;
|
||||
cpu.RAM[0x42] = 0x22;
|
||||
cpu.RAM[0x43] = is_PHC.Bytecode;
|
||||
cpu.RAM[0x44] = is_PHAB.Bytecode;
|
||||
cpu.RAM[0x45] = is_RTS.Bytecode;*/
|
||||
|
||||
/*cpu.RAM[0] = is_LDA_i.Bytecode;
|
||||
cpu.RAM[1] = 0x0;
|
||||
cpu.RAM[2] = is_LDB_i.Bytecode;
|
||||
cpu.RAM[3] = 0;
|
||||
cpu.RAM[4] = is_CMP.Bytecode;
|
||||
*/
|
||||
|
||||
|
||||
/*
|
||||
cpu.RAM[0xD0] = is_PLAB.Bytecode;
|
||||
cpu.RAM[0xD1] = is_PLCD.Bytecode;
|
||||
cpu.RAM[0xD2] = is_PHAB.Bytecode;
|
||||
cpu.RAM[0xD3] = is_LDAB_i.Bytecode;
|
||||
cpu.RAM[0xD4] = 0x8000;
|
||||
cpu.RAM[0xD5] = is_PHAB.Bytecode;
|
||||
cpu.RAM[0xD6] = is_LDAB_GPCD.Bytecode;
|
||||
cpu.RAM[0xD7] = is_CMP.Bytecode;
|
||||
cpu.RAM[0xD8] = is_BEQ_i.Bytecode;
|
||||
cpu.RAM[0xD9] = 0x00FB;
|
||||
cpu.RAM[0xDA] = is_STAB_sp.Bytecode;
|
||||
cpu.RAM[0xDB] = is_TCA.Bytecode;
|
||||
cpu.RAM[0xDC] = is_LDB_i.Bytecode;
|
||||
cpu.RAM[0xDD] = 1;
|
||||
cpu.RAM[0xDE] = is_ADD.Bytecode;
|
||||
cpu.RAM[0xDF] = is_BCS_i.Bytecode;
|
||||
cpu.RAM[0xE0] = 0x00EC;
|
||||
cpu.RAM[0xE1] = is_TAC.Bytecode;
|
||||
cpu.RAM[0xE2] = is_PLAB.Bytecode;
|
||||
cpu.RAM[0xE3] = is_PHCD.Bytecode;
|
||||
cpu.RAM[0xE4] = is_TBC.Bytecode;
|
||||
cpu.RAM[0xE5] = is_LDB_i.Bytecode;
|
||||
cpu.RAM[0xE6] = 1;
|
||||
cpu.RAM[0xE7] = is_ADD.Bytecode;
|
||||
cpu.RAM[0xE8] = is_TCB.Bytecode;
|
||||
cpu.RAM[0xE9] = is_PLCD.Bytecode;
|
||||
cpu.RAM[0xEA] = is_JMP_i.Bytecode;
|
||||
cpu.RAM[0xEB] = 0x00D5;
|
||||
cpu.RAM[0xEC] = is_TAC.Bytecode;
|
||||
cpu.RAM[0xED] = is_TDA.Bytecode;
|
||||
cpu.RAM[0xEE] = is_LDB_i.Bytecode;
|
||||
cpu.RAM[0xEF] = 1;
|
||||
cpu.RAM[0xF0] = is_ADD.Bytecode;
|
||||
cpu.RAM[0xF1] = is_TAD.Bytecode;
|
||||
cpu.RAM[0xF2] = is_PLAB.Bytecode;
|
||||
cpu.RAM[0xF3] = is_LDA_i.Bytecode;
|
||||
cpu.RAM[0xF4] = 1;
|
||||
cpu.RAM[0xF5] = is_ADD.Bytecode;
|
||||
cpu.RAM[0xF6] = is_TAB.Bytecode;
|
||||
cpu.RAM[0xF7] = is_LDA_i.Bytecode;
|
||||
cpu.RAM[0xF8] = 0;
|
||||
cpu.RAM[0xF9] = is_JMP_i.Bytecode;
|
||||
cpu.RAM[0xFA] = 0x00D5;
|
||||
cpu.RAM[0xFB] = is_PLAB.Bytecode;
|
||||
cpu.RAM[0xFC] = is_RTS.Bytecode;
|
||||
*/
|
||||
|
||||
cpu.RAM[0] = is_LDAB_i.Bytecode;
|
||||
cpu.RAM[1] = 0x0100;
|
||||
@ -125,12 +43,14 @@ cpu.RAM[0xEE] = is_RTS.Bytecode;
|
||||
|
||||
|
||||
stringToRAM("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc maximus erat mollis, fermentum quam at, blandit turpis. Pellentesque arcu tortor, smoke weed guam sagittis ac, posuere ut ipsum. Nulla facilisi. Mauris eget urna id sem porttitor consequat ultrices porttitor magna. Quisque condimentum porta viverra. Suspendisse ac condimentum ante. Duis accumsan augue urna, at ultricies nunc accumsan eget. Nullam eleifend.",cpu.RAM,0x100);
|
||||
//stringToRAM("Blackbeard420 is a Butt Fuckers",cpu.RAM,0x100);
|
||||
updateHTML();
|
||||
|
||||
let btn_clk = document.getElementById("btn_clk");
|
||||
let btn_runtil = document.getElementById("btn_runtil");
|
||||
let brkpt = document.getElementById("addrbrk");
|
||||
let clkinterval = document.getElementById("clkinterval");
|
||||
let clkcycles = document.getElementById("clkcycles");
|
||||
let btn_rst = document.getElementById("btn_rst");
|
||||
let clk_counter = document.getElementById("clk_counter");
|
||||
let clk_count = 0;
|
||||
@ -147,7 +67,9 @@ btn_clk.addEventListener('mouseup', function(evt) {
|
||||
|
||||
btn_runtil.addEventListener('click', function(evt) {
|
||||
let addr = parseInt("0x" + brkpt.value);
|
||||
RunUntilBreak(addr);
|
||||
let cpi = parseInt(clkcycles.value);
|
||||
console.log(`Running ${cpi} cycles per interval`);
|
||||
RunUntilBreak(addr,cpi);
|
||||
});
|
||||
|
||||
btn_rst.addEventListener('click', function(evt) {
|
||||
|
Loading…
Reference in New Issue
Block a user