Unofficial Hacker News companion — get notified on comment replies, and more.

Borland's DOS compilers, rebuilt from their own binaries (opens external site)

260 points by frostbyte7 2 days ago | github.com | 95 comments on HN | Vote on HN (opens Hacker News) |

View full thread · View on Hacker News

Comment thread (3)

  1. IMO there are two things that decompiling is useful for:

    1. Understanding how the program works. But for this you need a good decompilation, not just "portable assembly in C"

    2. Porting to a new platform. Once you have something that builds with a C compiler, you can rebuild it for a different platform, usually more performantly than running in an emulator. And it's often doable (if a lot of work) to also swap out graphics APIs, etc. But I'm not sure there's anyone who would care to run Borland DOS compilers on e.g. apple-aarch64, and DOSbox is more than good enough for anyone who does.

    Replies (2)
    1. Portable assembly in C is a good first step. Then you can start to name leaf functions and variables… and look for common inlined bits. You can confirm all your higher level transformations continue to produce equivalent bits.

      You can leave a model to crank on this for a couple of days and get something much closer to idiomatic source.

      It will not be THE source but it will be readable source that produces the same bits.

    2. Note that generating portable C is not as easy as generating "C that compiles to the same bytes", either.