97 lines
3.1 KiB
JavaScript
97 lines
3.1 KiB
JavaScript
let cpu = new CPU_8SA1();
|
|
GenerateMicrocode(Instructions,cpu);
|
|
|
|
|
|
cpu.RAM[0] = is_LDAB_i.Bytecode;
|
|
cpu.RAM[1] = 0x0100;
|
|
cpu.RAM[2] = is_PHAB.Bytecode;
|
|
cpu.RAM[3] = is_JSR.Bytecode;
|
|
cpu.RAM[4] = 0x00D0;
|
|
|
|
|
|
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; // printloop
|
|
cpu.RAM[0xD7] = is_CMP_gpab.Bytecode;
|
|
cpu.RAM[0xD8] = is_BEQ_i.Bytecode;
|
|
cpu.RAM[0xD9] = 0x00ED;
|
|
cpu.RAM[0xDA] = is_STAL_spin.Bytecode;
|
|
cpu.RAM[0xDB] = is_ADD_gpci.Bytecode
|
|
cpu.RAM[0xDC] = 1;
|
|
cpu.RAM[0xDD] = is_BCS_i.Bytecode;
|
|
cpu.RAM[0xDE] = 0x00E5;
|
|
cpu.RAM[0xDF] = is_PLAB.Bytecode;
|
|
cpu.RAM[0xE0] = is_ADD_gpai.Bytecode;
|
|
cpu.RAM[0xE1] = 1;
|
|
cpu.RAM[0xE2] = is_PHAB.Bytecode;
|
|
cpu.RAM[0xE3] = is_JMP_i.Bytecode;
|
|
cpu.RAM[0xE4] = 0x00D6;
|
|
cpu.RAM[0xE5] = is_ADD_gpdi.Bytecode; // rollover
|
|
cpu.RAM[0xE6] = 1;
|
|
cpu.RAM[0xE7] = is_PLAB.Bytecode;
|
|
cpu.RAM[0xE8] = is_ADD_gpbi.Bytecode;
|
|
cpu.RAM[0xE9] = 1;
|
|
cpu.RAM[0xEA] = is_PHAB.Bytecode;
|
|
cpu.RAM[0xEB] = is_JMP_i.Bytecode;
|
|
cpu.RAM[0xEC] = 0x00D6;
|
|
cpu.RAM[0xED] = is_PLAB.Bytecode; // return
|
|
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");
|
|
ramlines = document.getElementById("ramlines");
|
|
let btn_rst = document.getElementById("btn_rst");
|
|
let clk_counter = document.getElementById("clk_counter");
|
|
let clk_count = 0;
|
|
|
|
btn_clk.addEventListener('mousedown', function(evt) {
|
|
cpu.CLOCK(true);
|
|
clk_count++;
|
|
clk_counter.innerText = clk_count;
|
|
});
|
|
|
|
btn_clk.addEventListener('mouseup', function(evt) {
|
|
cpu.CLOCK(false);
|
|
});
|
|
|
|
|
|
btn_runtil.addEventListener('click', function(evt) {
|
|
let addr = parseInt("0x" + brkpt.value);
|
|
let cpi = parseInt(clkcycles.value);
|
|
console.log(`Running ${cpi} cycles per interval`);
|
|
RunUntilBreak(addr,cpi);
|
|
});
|
|
|
|
btn_rst.addEventListener('click', function(evt) {
|
|
cpu.PC = 0;
|
|
cpu.MCC = 0xf;
|
|
cpu.IR = 0;
|
|
cpu.DATABUS = 0;
|
|
cpu.ADDRBUS = 0;
|
|
cpu.MC_Controls = 0;
|
|
cpu.ALUSUM = 0;
|
|
cpu.RR = 0;
|
|
cpu.GPA = 0;
|
|
cpu.GPB = 0;
|
|
cpu.GPC = 0;
|
|
cpu.GPD = 0;
|
|
cpu.SR = 0;
|
|
cpu.SP = BITMASK_16;
|
|
|
|
clk_count = 0;
|
|
clk_counter.innerText = clk_count;
|
|
});
|
|
|
|
window.requestAnimationFrame(drawCPUInfo); |