So, I’ve made a PicoBlaze assembler and emulator in JavaScript. It mostly works in WebPositive, however, one crucial thing isn’t working. Namely, after the assembly is finished, it should be possible to download the hexadecimal (.HEX) file. Here is the code I am using for that:
function downloadHex() {
/*
Loosely based on:
https://stackoverflow.com/a/33622881/8902065
*/
if (/WebPositive/.test(navigator.userAgent))
alert(
"It's detected you are using WebPositive. 'Download Hexadecimal' didn't work there when we tested it.");
let hexadecimalString = "";
for (let i = 0; i < 2 ** 12; i++)
hexadecimalString += machineCode[i].hex + "\r\n";
let arrayOfBytes = new Uint8Array(hexadecimalString.length);
for (let i = 0; i < hexadecimalString.length; i++)
arrayOfBytes[i] = hexadecimalString.charCodeAt(i);
const blob = new Blob([ arrayOfBytes ], {
type : "application/binhex",
endings : "transparent",
});
const url = URL.createObjectURL(blob);
let link = document.createElement("a");
link.href = url;
link.download = "program.hex";
link.style.display = "none";
document.body.appendChild(link);
link.click();
link.remove();
}
In WebPositive, it starts “downloading”, but it keeps downloading forever. So, how can I make it work in WebPositive?