From time to time you buy an amazing good program but lacking icing on the cake. What to do? One method is patching - e.g. take a debugger (using CP/M (Z)SID for instance) and change the appropriate location(s) within the program. Of course this is useful for minimal changes only. Or write a new subroutine which must be appended at the end of the existing program. To enable this the new part must be activated by a corresponding patch, though.
I applied this to the JOYCE terminal program MAIL232 to adopt the settings of the serial line.
Both facilities should be used with great care because nobody knows for sure what a patch may cause.

It is more dramatically to use a disassembler. This means to produce a source file readable by an editor out of the (binary) program. Now the source may be altered by an editor. A modified executable program will be available after assembling the altered source. Inspired by a JOYCE user from Hamburg I tried to accomplish such a project using DASM. DASM had some restrictions which concerned the memory management. Fortunately DASM was in the Public Domain including the sources. Therefore DASM could be optimized accordingly.
Besides DASM another disassemblers are known to me which I had used sometimes.

As is generally known TURBO PASCAL compiles a .COM file including the complete run time library. This takes about 8kbytes of memory. In the early days TURBO PASCAL Version 3 ran also under MS-DOS 2.11. For that a commercial program did exist which removed unused routines from a .COM file and therefore executable were shortened accordingly. I planned this for CP/M, too. But in fact I disassembled the complete compiler and added some new functions and procedures.

A similar great effort of disassembling TURBO PASCAL was doing it for the Microsoft assembler M80. I disassembled and improved it - in my point of view.

To decompile1 a program written in a high level language (e.g. FORTRAN, PASCAL, C) is more complicated than disassembling a program written in assembler. In a first step the assembler source code will be created using a disassembler. Thereafter the source for the high level language will be converted from assembler source by hand. I performed this some times namely for the games

These programs were written for TURBO PASCAL originally. Decompilation is relatively „simple“ cause TURBO PASCAL works with a static run time library.
The utility TPCTL was very helpfull scanning a Turbo PASCAL .COM file and looking for two special run time routines. These routines follow data immediately. (This version of TPCTL detects programs compiled by TURBO Pascal versions 1, 2, 3 as well as 3A - the first version did only acknowledge Turbo PASCAL 3 .COM files).

For Example - compiled by Turbo PASCAL 3:
TURBO sourceCode generated
call 17BA
db   4
db   'Test'
The second routine will be found at address 054d.

(Another tool is OVLEXT.MAC. This utility allows to extract modules from an overlay file, writing it into a .COM-file.)
Back to the JOYCE activities

1. It doesn't exist an all-purpose decompile program which converts any binary file into a source of any high level language. On the one hand there exist a lot of high level languages and the binary code produced by the compilers of the same high level languages differ on the other hand. Find here some examples of binary code created from same sources.

Last updated: 2014 November 19