let cpu = new CPU_8SA1(); GenerateMicrocode(Instructions,cpu); cpu.RAM[0] = is_LDSPP_i.Bytecode; cpu.RAM[1] = 0xCF; cpu.RAM[2] = is_LDAB_i.Bytecode; cpu.RAM[3] = 0x0100; cpu.RAM[4] = is_PHAB.Bytecode; cpu.RAM[5] = is_PJSR.Bytecode; cpu.RAM[6] = 0x00D0; cpu.RAM[0x80000] = is_RTS.Bytecode; let v_printloop = 0xd9; let v_rollover = 0xe8; let v_return = 0xf0; let v_displayh = 0xd0; let v_displayl = 0x0; cpu.RAM[0xD0] = is_PLAB.Bytecode; cpu.RAM[0xD1] = is_PLCD.Bytecode; cpu.RAM[0xD2] = is_PHAB.Bytecode; cpu.RAM[0xD3] = is_LDA_i.Bytecode; cpu.RAM[0xD4] = v_displayh; cpu.RAM[0xD5] = is_PHA.Bytecode; cpu.RAM[0xD6] = is_LDAB_i.Bytecode; cpu.RAM[0xD7] = v_displayl; cpu.RAM[0xD8] = is_PHAB.Bytecode; cpu.RAM[0xD9] = is_LDAB_GPCD.Bytecode; // printloop cpu.RAM[0xDA] = is_CMP.Bytecode; cpu.RAM[0xDB] = is_BEQ_i.Bytecode; cpu.RAM[0xDC] = v_return; cpu.RAM[0xDD] = is_STAL_spin.Bytecode; cpu.RAM[0xDE] = is_ADD_gpci.Bytecode cpu.RAM[0xDF] = 1; cpu.RAM[0xE0] = is_BCS_i.Bytecode; cpu.RAM[0xE1] = v_rollover; cpu.RAM[0xE2] = is_PLAB.Bytecode; cpu.RAM[0xE3] = is_ADD_gpai.Bytecode; cpu.RAM[0xE4] = 1; cpu.RAM[0xE5] = is_PHAB.Bytecode; cpu.RAM[0xE6] = is_JMP_i.Bytecode; cpu.RAM[0xE7] = v_printloop; cpu.RAM[0xE8] = is_ADD_gpdi.Bytecode; // rollover cpu.RAM[0xE9] = 1; cpu.RAM[0xEA] = is_PLAB.Bytecode; cpu.RAM[0xEB] = is_ADD_gpbi.Bytecode; cpu.RAM[0xEC] = 1; cpu.RAM[0xED] = is_PHAB.Bytecode; cpu.RAM[0xEE] = is_JMP_i.Bytecode; cpu.RAM[0xEF] = v_printloop; cpu.RAM[0xF0] = is_PLAB.Bytecode; // return cpu.RAM[0xF1] = is_PRTS.Bytecode; stringToRAM("Welcome to the MatCat 8SA1 Computer Simulator!\n\nThis is a full hardware simulation of the computer to allow for easy development testing. It is currently a heavy work in progress as it is very early alpha, so check back often for new features!\n\n\nThis demo can be seen in the examples folder on the git page at: \nhttps://mygit.space/MatCat.OpenSource/8SA1Sim",cpu.RAM,0x100); //stringToRAM("Blackbeard420 is a Butt Fuckers",cpu.RAM,0x100); updateHTML(); let btn_clk = document.getElementById("btn_clk"); let btn_stopclk = document.getElementById("btn_stopclk"); 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`); btn_stopclk.disabled = false; RunUntilBreak(addr,cpi); }); btn_stopclk.addEventListener('click', function(evt) { btn_stopclk.disabled = true; clearInterval(intval); }); btn_rst.addEventListener('click', function(evt) { btn_stopclk.disabled = true; clearInterval(intval); cpu.PC = 0; cpu.MCC = 0xf; cpu.IR = 0; cpu.IR2 = 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; cpu.SPP = BITMASK_8; clk_count = 0; clk_counter.innerText = clk_count; for (let a = 0xd00000; a < 0xe00000; a++) { cpu.RAM[a] = 0; } }); window.requestAnimationFrame(drawCPUInfo);