lua-users home
lua-l archive

Disassembly toolchain

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


> Could you share your disassembly tool chain?
Certainly. It is the !VMview application in
http://www.wra1th.plus.com/lua/zip/rlua525.zip
but you need RISC OS to use it. Its !RunImage file is
#! lua -------------------------------
do
 local temp, src = arg[1], arg[2]
 local lines = io.lines
 local cpat = "^\t(%d+)\t%[(%d+)%]\t(.*)$"
 local x,y = {},{} -- source, comment
 for line in lines(src) do
 x[1+#x] = line
 end -- for
 local lnum,op
 local lfmt = "%6d\t%s"
 for line in lines(temp) do
 cline,lnum,op = line:match(cpat)
 if lnum and op then
 y[1+#y] = { tonumber(lnum),lfmt:format(tonumber(cline),op), }
 end -- if
 end -- for
 local concat = table.concat
 local fmt = "--[[\n%s\n--]]"
 local gather = function(n)
 local o = {}
 for _,v in ipairs(y) do
 if v[1] == n then o[1+#o] = v[2] end -- if
 end -- for
 return (#o > 0) and fmt:format(concat(o,"\n")) or ""
 end -- \
 local g
 for i,l in ipairs(x) do
 print(l)
 g = gather(i)
 if #g > 0 then print(g) end -- if
 end -- for
end ----------------------------------------
where arg[2] is the pathname of the program source and arg[1] is
the pathname of the output of luac (lhf was absolutely right) on
the source file with flags -p -l. How things are piped to turn this
into something where you just drag the icon of the program source
onto !VMview's iconbar icon, is somewhat OS-dependent, so I will not
strain your patience with the details.
-- 
Gavin Wraith (gavin@wra1th.plus.com)
Home page: http://www.wra1th.plus.com/

AltStyle によって変換されたページ (->オリジナル) /