Skip to content

Instantly share code, notes, and snippets.

@xorrbit
Forked from staticshock/bookmarklets.js
Created January 20, 2014 05:45
Show Gist options
  • Save xorrbit/8515480 to your computer and use it in GitHub Desktop.
Save xorrbit/8515480 to your computer and use it in GitHub Desktop.
// Bind F7 to 'step'
javascript:$(document).bind('keydown', function(e) { e.which == 118 && parse('s'); }); void(0)
// Add a 'readhex' command that works just like 'read' but dumps nothing but the hex
javascript:cpu._readhex =
function(e) {
if (!e[1]) return write(" Please give an expression to read the memory at."), void 0;
var t = cpu.to_addr(e[1]);
cpu.get("/cpu/dbg/memory/" + t + "?len=" + (parseInt(e[2], 16) + (15 - parseInt(e[2], 16) & 15) || 32), function(e) {
for (var n = atob(e.raw), i = "", o = " ", s = 0; s < n.length; s++) s % 2 == 0 && (o += " "), o += pad(n.charCodeAt(s).toString(16), 2), s % 8 == 7 && (i += " " + o + "\n", o = " ");
write(i);
})
}; void(0)
// Add a 'disassemble' command that takes the same arguments as read/readhex
// and disassembles the instructions starting at that address
javascript:cpu._disassemble =
function(e) {
if (!e[1]) return write(" Please give an expression to read the memory at."), void 0;
var t = cpu.to_addr(e[1]);
cpu.get("/cpu/dbg/memory/" + t + "?len=" + (parseInt(e[2], 16) + (15 - parseInt(e[2], 16) & 15) || 32), function(e) {
for (var n = atob(e.raw), i = "", o = "", s = 0; s < n.length; s++) s % 2 == 0 && (o += ""), o += pad(n.charCodeAt(s).toString(16), 2), s % 8 == 7 && (i += o, o = "");
cpu.get("/cpu/dbg/disasm?obj=" + i, function(e) {
write(e.error ? "ERROR: " + e.error : e.data.insns.join("\n"));
}, 1)
})
}; void(0)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment