add string to hex dump
This commit is contained in:
parent
ceb4a457f7
commit
06dc63ce74
@ -455,6 +455,12 @@ local function disassembleHex(hex, arch)
|
||||
disassembleMemory(memToHex(hex), arch)
|
||||
end
|
||||
|
||||
local printableCharsS = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789`-=[]\\;\',./~!@#$%^&*()_+{}|:\"<> "
|
||||
local printableChars = {}; for i = 1, #printableCharsS do printableChars[printableCharsS:sub(i, i)] = true end;
|
||||
local function toPrintableChar(n)
|
||||
local c = string.char(n)
|
||||
return printableChars[c] and c or "?"
|
||||
end
|
||||
local function printMemory(mem)
|
||||
print("Memory Dump:")
|
||||
local anynonempty = false
|
||||
@ -469,17 +475,21 @@ local function printMemory(mem)
|
||||
end
|
||||
for base = 0, 0xFFF0, 16 do
|
||||
local line = {}
|
||||
local strt = {}
|
||||
local nonempty = false
|
||||
for addr = base, base+15 do
|
||||
if addr%4==0 then table.insert(line, " ") end
|
||||
if mem[addr]==false then
|
||||
nonempty = true
|
||||
table.insert(line, "XX ")
|
||||
table.insert(strt, "X")
|
||||
elseif mem[addr] then
|
||||
nonempty = true
|
||||
table.insert(line, string.format("%02X", mem[addr]).." ")
|
||||
table.insert(strt, toPrintableChar(mem[addr]))
|
||||
else
|
||||
table.insert(line, "-- ")
|
||||
table.insert(strt, "-")
|
||||
end
|
||||
end
|
||||
if nonempty then
|
||||
@ -487,7 +497,7 @@ local function printMemory(mem)
|
||||
if l~=lastline or base~=lastbase+16 then
|
||||
closereps(base-16)
|
||||
if base ~= lastbase+16 then print("...") end
|
||||
print(string.format("%04X", base).." |"..l)
|
||||
print(string.format("%04X", base).." | "..l.." | "..table.concat(strt))
|
||||
else
|
||||
numreps = numreps+1
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user