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)
|
disassembleMemory(memToHex(hex), arch)
|
||||||
end
|
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)
|
local function printMemory(mem)
|
||||||
print("Memory Dump:")
|
print("Memory Dump:")
|
||||||
local anynonempty = false
|
local anynonempty = false
|
||||||
@ -469,17 +475,21 @@ local function printMemory(mem)
|
|||||||
end
|
end
|
||||||
for base = 0, 0xFFF0, 16 do
|
for base = 0, 0xFFF0, 16 do
|
||||||
local line = {}
|
local line = {}
|
||||||
|
local strt = {}
|
||||||
local nonempty = false
|
local nonempty = false
|
||||||
for addr = base, base+15 do
|
for addr = base, base+15 do
|
||||||
if addr%4==0 then table.insert(line, " ") end
|
if addr%4==0 then table.insert(line, " ") end
|
||||||
if mem[addr]==false then
|
if mem[addr]==false then
|
||||||
nonempty = true
|
nonempty = true
|
||||||
table.insert(line, "XX ")
|
table.insert(line, "XX ")
|
||||||
|
table.insert(strt, "X")
|
||||||
elseif mem[addr] then
|
elseif mem[addr] then
|
||||||
nonempty = true
|
nonempty = true
|
||||||
table.insert(line, string.format("%02X", mem[addr]).." ")
|
table.insert(line, string.format("%02X", mem[addr]).." ")
|
||||||
|
table.insert(strt, toPrintableChar(mem[addr]))
|
||||||
else
|
else
|
||||||
table.insert(line, "-- ")
|
table.insert(line, "-- ")
|
||||||
|
table.insert(strt, "-")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if nonempty then
|
if nonempty then
|
||||||
@ -487,7 +497,7 @@ local function printMemory(mem)
|
|||||||
if l~=lastline or base~=lastbase+16 then
|
if l~=lastline or base~=lastbase+16 then
|
||||||
closereps(base-16)
|
closereps(base-16)
|
||||||
if base ~= lastbase+16 then print("...") end
|
if base ~= lastbase+16 then print("...") end
|
||||||
print(string.format("%04X", base).." |"..l)
|
print(string.format("%04X", base).." | "..l.." | "..table.concat(strt))
|
||||||
else
|
else
|
||||||
numreps = numreps+1
|
numreps = numreps+1
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user