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 had some restrictions which concerned the memory management.
DASM was in the Public Domain including the sources.
DASM could be optimized accordingly.
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.
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
TPCTLwas 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
versiondid only acknowledge Turbo PASCAL 3 .COM files).
|TURBO source||Code generated|
call 17BA db 4 db 'Test'
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.|