Created
June 4, 2014 01:44
-
-
Save newfurniturey/19d263757a392c1c98c5 to your computer and use it in GitHub Desktop.
microcorruption - print executing instructions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// event used to submit the form | |
var keydownEvent = $.Event('keydown', { which: 13 }); | |
// input field that takes user-instructions | |
var $entry = $('#textentry'); | |
// text blocks that we're interested in | |
var executingBytes = document.getElementById('insnbytes'); | |
var decodedBytes = document.getElementById('insndecoded'); | |
// bind to the decodedByte text block and watch for any changes | |
$('#insndecoded').bind('DOMSubtreeModified', function() { | |
if (decodedBytes.innerHTML == '') return; | |
console.log( | |
// the current value of PC | |
document.getElementById('reg0').innerHTML | |
// the bytes being executed | |
+ ': ' + executingBytes.innerHTML | |
// pad the bytes for an even-spacing display | |
+ Array(14 - executingBytes.innerHTML.trim().length).join(' ') | |
// the decoded instructions | |
+ ' ' + decodedBytes.innerHTML | |
); | |
if (!$('#io_input_box').is(':visible')) { | |
// if the current instruction didn't invoke the I/O dialog, | |
// submit a new "step" instruction | |
$entry.val('s'); | |
$entry.trigger(keydownEvent); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment