203 lines
5.7 KiB
JavaScript
203 lines
5.7 KiB
JavaScript
let cpu = new CPU_8SA1();
|
|
GenerateMicrocode(Instructions,cpu);
|
|
|
|
cpu.RAM[0] = is_LDSPP_i.Bytecode;
|
|
cpu.RAM[1] = 0xCF;
|
|
|
|
cpu.RAM[2] = is_LDA_i.Bytecode;
|
|
cpu.RAM[3] = 1;
|
|
cpu.RAM[4] = is_STAL_a24.Bytecode;
|
|
cpu.RAM[5] = 0xFF;
|
|
cpu.RAM[6] = 0x0;
|
|
cpu.RAM[7] = is_LDAB_i.Bytecode;
|
|
cpu.RAM[8] = 0x0100;
|
|
cpu.RAM[9] = is_PHAB.Bytecode;
|
|
cpu.RAM[10] = is_JSR_a.Bytecode;
|
|
cpu.RAM[11] = 0x00D0;
|
|
cpu.RAM[12] = is_LDAB_i.Bytecode;
|
|
cpu.RAM[13] = 0x0101;
|
|
cpu.RAM[14] = is_STAL_a24.Bytecode;
|
|
cpu.RAM[15] = 0xFF;
|
|
cpu.RAM[16] = 0x1;
|
|
cpu.RAM[17] = is_ADD.Bytecode;
|
|
cpu.RAM[18] = is_NOPL.Bytecode;
|
|
cpu.RAM[19] = is_NOPL.Bytecode;
|
|
cpu.RAM[20] = is_NOPL.Bytecode;
|
|
cpu.RAM[21] = is_NOPL.Bytecode;
|
|
cpu.RAM[22] = is_NOPL.Bytecode;
|
|
cpu.RAM[23] = is_NOPL.Bytecode;
|
|
cpu.RAM[24] = is_NOPL.Bytecode;
|
|
cpu.RAM[25] = is_NOPL.Bytecode;
|
|
cpu.RAM[26] = is_NOPL.Bytecode;
|
|
cpu.RAM[27] = is_NOPL.Bytecode;
|
|
cpu.RAM[28] = is_NOPL.Bytecode;
|
|
cpu.RAM[29] = is_BCC_a.Bytecode;
|
|
cpu.RAM[30] = 17;
|
|
cpu.RAM[31] = is_JMP_a.Bytecode;
|
|
cpu.RAM[32] = 0x0;
|
|
|
|
|
|
/*
|
|
|
|
// Experimenting with 16 bit add
|
|
cpu.RAM[2] = is_LDAB_i.Bytecode;
|
|
cpu.RAM[3] = 0x1337;
|
|
cpu.RAM[4] = is_ADD_aab16.Bytecode;
|
|
cpu.RAM[5] = 0b1111000011101001;
|
|
cpu.RAM[6] = is_ADD_aab16_2.Bytecode;
|
|
cpu.RAM[7] = is_STAB_a.Bytecode;
|
|
cpu.RAM[8] = 0x0020;
|
|
*/
|
|
|
|
|
|
/*
|
|
|
|
// Experimenting with thread interrupt
|
|
cpu.RAM[2] = is_STI.Bytecode;
|
|
cpu.RAM[3] = 0x80;
|
|
|
|
cpu.RAM[4] = is_LDAB_i.Bytecode;
|
|
cpu.RAM[5] = 0x0100;
|
|
cpu.RAM[6] = is_PHAB.Bytecode;
|
|
cpu.RAM[7] = is_JSR_a.Bytecode;
|
|
cpu.RAM[8] = 0x00D0;
|
|
|
|
cpu.RAM[0x80] = is_CTI.Bytecode;
|
|
cpu.RAM[0x81] = 0x7F;
|
|
cpu.RAM[0x82] = is_JMP_a.Bytecode;
|
|
cpu.RAM[0x83] = 0x04;
|
|
*/
|
|
|
|
|
|
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_cda.Bytecode; // printloop
|
|
cpu.RAM[0xDA] = is_CMP.Bytecode;
|
|
cpu.RAM[0xDB] = is_BEQ_a.Bytecode;
|
|
cpu.RAM[0xDC] = v_return;
|
|
cpu.RAM[0xDD] = is_STAL_spa24.Bytecode;
|
|
cpu.RAM[0xDE] = is_ADD_gpci.Bytecode
|
|
cpu.RAM[0xDF] = 1;
|
|
cpu.RAM[0xE0] = is_BCS_a.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_a.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_a.Bytecode;
|
|
cpu.RAM[0xEF] = v_printloop;
|
|
cpu.RAM[0xF0] = is_PLAB.Bytecode;
|
|
cpu.RAM[0xF1] = is_PLA.Bytecode; // return
|
|
cpu.RAM[0xF2] = is_RTS_a.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 btn_saveram = document.getElementById("btn_saveram");
|
|
let txt_ramaddr = document.getElementById("txt_ramaddr");
|
|
let txt_ramval = document.getElementById("txt_ramval");
|
|
|
|
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;
|
|
updateHTML();
|
|
});
|
|
|
|
btn_clk.addEventListener('mouseup', function(evt) {
|
|
cpu.CLOCK(false);
|
|
updateHTML();
|
|
});
|
|
|
|
|
|
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);
|
|
updateHTML();
|
|
});
|
|
|
|
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;
|
|
}
|
|
updateHTML();
|
|
|
|
});
|
|
|
|
btn_saveram.addEventListener('click', function(evt) {
|
|
cpu.RAM[parseInt(txt_ramaddr.value)] = parseInt("0x" + txt_ramval.value);
|
|
updateHTML();
|
|
});
|
|
|
|
txt_ramaddr.addEventListener('change', function(evt) {
|
|
txt_ramval.value = formatHex(cpu.RAM[parseInt(txt_ramaddr.value)],4);
|
|
});
|
|
|
|
|
|
//window.requestAnimationFrame(drawCPUInfo);
|
|
updateHTML(); |