Sine Table Generator
Clear outputs
▶ Run
Source — JavaScript (editable)
function generateSineTable(filename, valueCount) { valueCount = valueCount || 256; let fileOutput = ""; let consoleOutput = ""; consoleOutput += " This program creates a table of sine values \n"; consoleOutput += " Written by Rue Mohr 2003 \n"; consoleOutput += " 256 Degrees, 8 bit values 0 - 255 \n"; for (let t = 0; t < valueCount; t++) { const tb = t * (Math.PI / (valueCount / 2)); const value = Math.trunc(128 + (Math.sin(tb) * 128)); if (t % 8 === 0) { consoleOutput += "\n DB "; fileOutput += "\n DB "; } else { fileOutput += ", "; } consoleOutput += " " + String(value).padStart(4) + " "; fileOutput += " " + value + " "; } consoleOutput += "\n"; fileOutput += "\n"; return { fileOutput, consoleOutput }; } const result = generateSineTable("sine_table.asm"); output(result.fileOutput); console_out(result.consoleOutput);
File output — sine_table.asm
↓ Download
Console / printf output
↓ Download