Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions assembler.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,41 @@ function SimulatorWidget(node) {
$node.find('.stepButton').click(simulator.debugExec);
$node.find('.gotoButton').click(simulator.gotoAddr);
$node.find('.notesButton').click(ui.showNotes);
$node.find('.saveButton').click(function () {
let file = new Blob([$node.find('.code').val()], {type: "text/x-asm"});
if (window.navigator.msSaveOrOpenBlob) // IE10+
window.navigator.msSaveOrOpenBlob(file, "main.asm");
else {
let a = document.createElement("a");
let url = URL.createObjectURL(file);
a.href = url;
a.Style = "display: none;";
a.download = "main.asm";
document.body.appendChild(a);
a.click();
setTimeout(function() {
document.body.removeChild(a);
window.URL.revokeObjectURL(url);
}, 0);
}
});
$node.find('.loadButton').click(function () {
let fileInput = document.createElement("input");
fileInput.type = "file";
fileInput.accept = "text/x-asm, text/plain";
fileInput.style = "display: none;";
fileInput.click();
fileInput.addEventListener('change', function() {
let file = this.files[0];
if (file) {
let reader = new FileReader();
reader.addEventListener("load", () => {
$node.find('.code').val(reader.result);
});
reader.readAsText(file);
}
})
});
$node.find('.code').keypress(simulator.stop);
$node.find('.code').keypress(ui.initialize);
$(document).keypress(memory.storeKeypress);
Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
<input type="button" value="Hexdump" class="hexdumpButton" />
<input type="button" value="Disassemble" class="disassembleButton" />
<input type="button" value="Notes" class="notesButton" />
<input type="button" value="Save" class="saveButton" />
<input type="button" value="Load" class="loadButton" />
</div>

<textarea class="code"></textarea>
Expand Down