afc@shibaya.lonestar.org (Augustine Cano) (12/29/90)
Hello net.land: I need to find out what assembler code is generated by compilers/optimizers. The first thing that comes to mind is: compile x programs and look at the assembler output. This is highly inefficient for various reasons: much of the code would be duplicated (who needs to wade through the assembler generated by passing a parameter by reference 200 times?), a real program converts to possibly thousands of lines of assembler and some C instructions/ constructs will most likely be missing. The next thing that comes to mind is a bare bones program whose whole purpose is to use each C instruction/construct once, with function and/or variable names such that the particular item can be quickly located in the (many) lines of assembler generated. This would make it relatively easy to connect assembly code with the C instruction that generated it, for any compiler/cpu type, without extraneous garbage in the way. Has anybody seen something like this? I'd rather not duplicate effort if someone has even parts of this. Taking care of every case of indirection, double indirection, types, sizes etc... is likely to be not a trivial undertaking. Such a program could be the "training" part for a universal de-compiler. Once the assembler output of a specific compiler/cpu type has been generated from this program, the de-compiler could then re-generate the original C source (within limits). Part 2 would obviously be more difficult to implement and I suspect such a thing only exists now for specific cpu types (and for significant $s too). In any case I'm only interested in the "training" part now. Any code, suggestions, references, etc... are welcome. BTW, compiler textbooks are too general and incomplete for my needs. Thanks. -- Augustine Cano INTERNET: afc@shibaya.lonestar.org UUCP: ...!{ernest,egsner}!shibaya!afc
wallis@labc.enet.dec.com (Barry L. Wallis) (12/30/90)
In article <1990Dec28.220115.15930@shibaya.lonestar.org>, afc@shibaya.lonestar.org (Augustine Cano) writes... |> |>The next thing that comes to mind is a bare bones program whose whole purpose |>is to use each C instruction/construct once, with function and/or variable |>names such that the particular item can be quickly located in the (many) |>lines of assembler generated. This would make it relatively easy to |>connect assembly code with the C instruction that generated it, for any |>compiler/cpu type, without extraneous garbage in the way. |> You may want to try using something like Borland's Turbo Debugger VIEW-CPU window. This will show you each source line with the relevant assembler code beneath it. You can dump this to the logwindow and write it to disk. BTW, what are you planning to do about optimizations (e.g., the same source line(s) may generate different code depending on other source lines). --- Barry L. Wallis USENET: wallis@labc.dec.com Database Consultant Prodigy (don't laugh): DNMX41A U.S. DECtp Resource Center DECUServe: EISNER::WALLIS (not on the net yet) Los Angeles, CA "No one voted for me, I represent myself" ---