let isalist = document.getElementById("isa_list"); let ISAPrepList = new Array(); function hasInstruction(ins) { for (let a = 0; a < ISAPrepList.length; a++) { if (ISAPrepList[a].Mnemonic.toLowerCase() === ins.Mnemonic.toLowerCase()) { return a; } } return false; } for (let a = 0; a < Instructions.length; a++) { if (hasInstruction(Instructions[a]) === false) { ISAPrepList.push({Mnemonic: Instructions[a].Mnemonic,LongName: Instructions[a].LongName,Varients: new Array(Instructions[a])}); } else { console.log(`${Instructions[a].Mnemonic} IS ALREADY THERE LETS ADD TO IT`); ISAPrepList[hasInstruction(Instructions[a])].Varients.push(Instructions[a]); } } let outHTML = ""; ISAPrepList.sort((a, b) => (a.Bytecode > b.Bytecode) ? -1 : 1); for (let a = 0; a < ISAPrepList.length; a++) { outHTML += `
`; outHTML += `

${ISAPrepList[a].Mnemonic}    ${ISAPrepList[a].LongName}

`; outHTML += ``; outHTML += ``; outHTML += ``; outHTML += ``; for (let b=0; b < ISAPrepList[a].Varients.length; b++) { let operandtext = ""; for (let c = 0; c < ISAPrepList[a].Varients[b].Operands.length; c++) { let operandresult = ISAPrepList[a].Varients[b].Operands[c].Operand; let ogor = operandresult; if (operandresult === "#") operandresult = ""; if (operandresult === "$" || operandresult === "") { switch (Math.floor(Math.random() * 9)) { case 0: case 1: case 2: case 3: { operandresult = ((ogor === "#") ? "" : ogor) + formatHex(Math.floor(Math.random() * (2 ** ISAPrepList[a].Varients[b].Operands[c].Bitwidth)), ((ISAPrepList[a].Varients[b].Operands[c].Bitwidth === 16) ? 4 : 2)) + "h"; break; } case 4: case 5: case 6: case 7: { operandresult = ((ogor === "#") ? "" : ogor) + Math.floor(Math.random() * (2 ** ISAPrepList[a].Varients[b].Operands[c].Bitwidth)); break; } case 8: { operandresult = ((ogor === "#") ? "" : ogor) + "MyVar"; break; } } } if (ogor === "#") operandresult = "[" + operandresult + "]"; operandtext += ` ${operandresult},`; } operandtext = operandtext.substring(0,operandtext.length-1); outHTML += ``; outHTML += ``; outHTML += ``; } outHTML += `
Address ModeExampleBytecodeWordsCycles
${ISAPrepList[a].Varients[b].Type}${ISAPrepList[a].Mnemonic}${operandtext}0x${formatHex(ISAPrepList[a].Varients[b].Bytecode,4)}${ISAPrepList[a].Varients[b].Words}${ISAPrepList[a].Varients[b].Cycles}
`; outHTML += `
`; } isalist.innerHTML = outHTML;