The Esstu Pack

Index

DisAsm

Partly as an exercise based on the information in nasm's documentation, and partly for utility, I wrote a disassembler for 80x86 assembler, to support all the opcodes nasm supports. This code (and also this documentation - sorry!) is clearly and most definitely ALPHA. Use at your own risk. However I give you my word that if used right, this program shouldn't damage any file except DISASM.ASM (the output file) which it replaces with each run.

Usage is simple. Just run DISASM.CMD, passing it one argument, the name of the file to disassemble. Note: Only pure binary files are supported. DisAsm doesn't (yet) support .EXE files. This may come later. No promises.

Some opcodes are not yet supported, and will generate 'DB' (deposit byte, used to put raw hex bytes into the assembled file) commands, and may cause misalignment of instructions. Sorry - can't be helped until I get all the code entered. However, if you find any case of both the disassembled command and the byte code produced from assembling that command being different from the input, please tell me. (There are several cases of different commands producing the same opcodes, such as SHL and SAL, and several others of different opcodes meaning the same command, such as PUSH BX (1-byte and 2-byte versions of the same command), where nasm will always pick the same one, but this disassembler, like most, will disassemble both.)

DisAsm cannot, of course, distinguish between code and data, and will happily disassemble data as code. In this it is very similar to DOS's DEBUG. However with DEBUG you can resync with the code by starting disassembly at a specific offset. Such a feature may eventually be added, but no promises. Sorry.

As an example (and a demonstration of the size increase - 14KB to 100KB!), a disassembled version of the program's own source has been included. Running DISASM.ASM through nasm (using the binary output format, and 16-bit code) produces a file identical to DISASM.CMD except for an extra NULL byte at the end (placed there to pad out the last command).

A word or two (!) of warning: As this program is open source, someone will almost certainly want to tinker. (Everyone else can skip these paragraphs.) This is quite acceptable, but you'd better know a little about the innards of the program so you won't damage anything!

The output for each opcode is determined by a stem, hashed on the hexadecimal opcode value. The appropriate command is INTERPRETed, so it can contain any REXX command, but most consist of a CALL to LINEOUT, writing a line to the output file. For the rest, just explore the code, taking note especially of comments starting /** or /*** - these are limitation or poor compatibility notes.

There are, as yet, a large number of limitations (of course). 32-bit code currently isn't supported, but I intend to add that. Mixed 32-bit and 16-bit code will come at the same time. Other limitations are mentioned in the source, which (with this page) consists of the entire documentation as well. If enough people ask (and perhaps if they offer some of those lovely pieces of plastic marked with a number and the word 'DOLLARS' <g>), I might see about writing some real docs. Otherwise, just RTFS.

File: DISASM.ZIP
Requires: REXX
Installation: None.
Operation: Run with arguments.
De-installation: Delete.
Distribution: Open Source.