r/AskReverseEngineering • u/Nattfarinn • Nov 04 '22
How to decompile unoptimized bytecode?
Hello there,
I know the answer to how decompile bytecode back to readable code is a Holy Grail or Philosopher Stone, but I am curious how it works for non-optimized compiled assembly?
I have custom assembly language for registerless stack machine. I am pretty sure compiler does not optimize the bytecode, it is more-less just transcriber of readable code into static assembly structures of linear execution.
I have written disassembler and it works pretty well. What I struggle with right now is how to identify these structures and their purpose. While the structures themselves may be static and they occur one after another (well, kind-of, there are still encapsulated code blocks), it is bytecode/assembly nonetheless so within the structures there can be quite a lot of jumping around to other addresses/labels.
How to approach writing decompiler for such assembly? Is it even possible?
If anyones wonder, the assembly is from compiled SOP scripts from AESOP game engine (Eye of Beholder 3, Dungeon Hack). I have full documentation of SOP language, and source code of a compiler as well.
Assembly example and bytecodes, thanks to WayBackMachine: https://web.archive.org/web/20160805222221/http://rewiki.regengedanken.de/wiki/AESOP_bytecode_list and a bit more here https://web.archive.org/web/20160524142441/http://rewiki.regengedanken.de/wiki/EYE.RES
If my question doesn't make sense or I use vague/wrong terms, please forgive me, I am not familiar (yet) with RE terminology. But I hope you will understand what I mean.
View all comments
Show parent comment
2
u/Nattfarinn Nov 04 '22
Thank you! I had no clue there is a soft that allows you to model custom VM architecture. Sounds like science-fiction to me; I will try it out asap.