

But without the AST it's not, and even then you'd lose all comments etc. So I have /many/ times been asked for a (Pascal etc.) decompiler, by people who thought that since a BASIC program could be listed one written in Pascal was similarly amenable to inspection. Net, OTOH, in effect distributes the AST as the executable, with the final stages (optimise and convert to opcodes in memory) done at load time.Įven more accessibly, a traditional BASIC would effectively ship a compressed version of the entire source to the end user, making it trivial to list. possibly with debugging xrefs to the lines in the original source, but without incorporating either the source or enough information to reconstruct the AST.


A compiler like Turbo Pascal or FPC takes the AST, optimises it, and spits out an executable. The key is that when a program in a high-level language is compiled it's first changed into an Abstract Syntax Tree (AST). Hell, after all these years working with this sort of stuff /I/ find them daunting.

To be blunt without intending to cause offence, it will be faster for him to find the source than for you to learn IDA or Ghidra. If all you want is to analyze a handful of functions in the program then those utilities/dis-assemblers/"decompilers" are definitely helpful. Dis-assemblers are very helpful to investigate a program, not recreating it, provided their user is completely comfortable with Assembler. That said, their "decompilation" can be helpful to see the structural flow of a function. Also, there are some programs out there billing themselves as "decompilers", IDA Pro has a "decompiler" plug-in, Ghidra offers "decompilation" too as do a number of other programs but, only someone who confuses a dog turd with Swiss chocolate (or someone who'll say anything to get your money) would call the result a "decompilation". IF settling for an assembly file that operates the same as the original program is "acceptable" then a tool like IDA Pro can definitely be very helpful in getting you there but, as far as getting the Pascal source back, simply forget it. A DOS type program without debugging symbols is extremely laborious to recreate. If the executable has debug symbols in it then a program like IDA Pro can provide some _assistance_ in your rewriting it.
