📄 objasm.doc
字号:
O B J A S M
An object file to assembly language file conversion utility
INTRODUCTION
------------
Under normal compilation procedures, most programs are converted into an
intermediate notation before being converted into executable code. This
notation simplifies the process of managing large programs by allowing the
programmer to divide a program into many modules. When changes are made
to a module, the programmer need only compile that module rather than
the entire program. For most 80x86 and compatible processors, this notation
is stored in a .OBJ file.
After compilation, the .OBJ file must be converted into a machine
executable form. At this stage the various modules must be combined and
any inter-module dependencies must be resolved. This process is called
linking and is accomplished by LINK, LINK86, or PLINK86 (depending on which
vendor you purchase it from). In order to accomplish this resolving, the
inter-module dependancy information must be stored in the .OBJ file. This
information normally consists of routine names, variable names, and other
globally known quantities.
For the most part, once a program has been compiled into its .OBJ file,
there is no going back. There is no way to convert the .OBJ file back into
its appropriate language. It is for that reason that many companies who wish
to sell thier proprietary routines to programmers, do so in the .OBJ file
form. Normally these companies send out a library file (.LIB). .LIB files
contain one or more .OBJ files. The program which groups .OBJ files into an
.LIB file is known as LIB, LIB86, or PLIB86. This method of distribution
has made routine vendors happy for many years.
But this distribution of encoded routines has meant headaches for
programmers. Programmers who discovered bugs in the routines, or wanted to
make enhancements had to contact the vendor and plead for help. The
programmers were at the mercy of the routine vendors.
Fortunately, OBJASM came along. OBJASM is a utility which can convert
.OBJ files back into assembly language, much like a dis-assembler. Unlike
a dis-assembler however, OBJASM is able to determine the names of the routines
that it is dis-assembling. Globally known data names can be determined as
well. OBJASM is also able to determine the segments of the original routines.
Segments are logical/physical divisions of sections of routines, normal
segments are code, data, stack, etc. With this additional knowledge, OBJASM
is able to produce an assembly language listing which is easier to read, easier
to understand, and easier to modify than normal dis-assembler output.
OBJASM output is compatible with MASM version 4.0 or later. It runs
under MS-DOS version 3.0 or later although it is able to process .OBJ files
(as specified by INTEL, document order no. 121748-001) from many other 80x86
operating systems such as CPM-86, XENIX 80x86, OS/2 and more. I believe that
the format for UNIX (it has .o files) is completely different.
COMPILING OBJASM
----------------
OBJASM was written for Microsoft C version 4.0 or later, and there is
a supplied 'make' file for that environment. To execute the 'make' file,
set-up your Microsoft C environment and go to the directory which contains
the OBJASM source files. Make sure that you have the Microsoft C utility
programs reachable using your 'PATH' environment variable, and type 'MAKE O'
from the dos prompt. The compilation will proceed to compile OBJASM for
the large model.
One of the modules (ouinsert.c) will give a compiler warning message, or
may fail depending how picky you have set your compiler. The message has
something to do with 'casting far pointer to long' or vice-versa. Make sure
your compiler gives only a warning message and proceeds with the compilation
process. The warning message can be ignored. Data structure fanatics: the
program uses threaded balanced binary trees for many internal lists and the
ouinsert module is the insert-into-a-list function. The root node of each tree
has the tree's height (an integer) stored into one of the structures
pointer type members. This is non-portable C code, but it's ok for most C
compilers. These threaded balanced binary tree routines were taken from a
set of generic list handling functions.
The modules contained in OBJASM are as follows:
omain.c main() processes command line and passes through input file
oprocess.c dis-assembly/dumping controlling routines
odisasm.c routines to dis-assembly the various kinds of 80x86
instructions
oreport.c routines to display some of the internal lists (publics and
externals)
ooutput.c routines to display various pieces of the dis-assembled .OBJ
routine
orXXXXXX.c (all except oreport.c) routines to process the various INTEL
standard .OBJ record formats
oubuff.c buffer I/O routines for the input file
ouinsert.c list insertion routine
oufind.c list searching routine
ounewtre.c list creation routine
ouinitre.c initialize all lists
oufmterr.c .OBJ format error handling routine
ouget.c input file formating (into chars,ints,longs,etc) routines
oumalloc.c internal memory allocation routine (with check for out of
memory error)
oustruct.c assembly language structure routines
oextra.c additional information file processing routines
In addition, some of the modules (omain for example) have some debugging
statements conditionally compiled. If OBJASM exhibits strange behavior and
you wish to trace it down, re-compile these modules with the /DDEBUG option
(for MSC). This will define the preprocessor variable DEBUG, which will
enable the conditionally compiled debugging statements.
EXECUTING OBJASM
----------------
OBJASM is executed from the command line as:
OBJASM -options filename
OBJASM -options filename.OBJ
If you are dis-assembling a .LIB file, then you must use your LIB, LIB86, or
PLIB86 utility to extract the .OBJ files.
All output is sent to standard output (normally the console), but can be re-
directed using the '>' symbol. A normal OBJASM execution would look like this:
OBJASM OMAIN >OMAIN.ASM
The output would then be stored in the file omain.asm. Output contains tab
(control-I) characters to seperate the various assembly language columns.
A normal line format would appear as:
[LABEL]: (tab) [INSTRUCTION] (tab) [OPERANDS] (tab) ;[COMMENT]
start: mov ds,ax ; dummy comment
The options currently available for OBJASM are as follows:
Option Description
------ ---------------------------------------------------------------
-4 Make MASM v4.0 compatible output (No retf)
-a Add labels for better output (use with EXEOBJ)
-h Add hex comments showing bytes dis-assembled
-r Make RASM86 compatible output (special segment directives, etc)
-c Set the minimum size in a code segment, this option is followed
by a number which represents the new value. Eg. -c20
-s Set the minimum size in a data segment, this option is followed
by a number which represents the new value. Eg. -s10
-f Specifies an additional information file. The additional information
file must be given in parenthesis. Eg. -f(myfile) The additional
information file's default extension is ".add", as in the example
above, the file specified would be "myfile.add". For more
information see the ADDITIONAL INFORMATION FILE section.
Technical Information
---------------------
Most information used in writing OBJASM was taken from the following
public documents:
INTEL 8086 RELOCATABLE OBJECT MODULE FORMATS (Order No. 121748-001)
MICROSOFT OMF Specification (Dated February 18,1986; this is an edited
copy of the INTEL document)
MS-DOS ENCYCLOPEDIA
These documents describe the .OBJ file format. Here is a quick
summarization of the format. Each .OBJ file contains one or more records.
Each record has a record type (which specifies its purpose), a record length,
and record data (which depends on the record type). INTEL outlines 30
different record types, most of which are never used. MICROSOFT added to
these record types and removed the ones which it didn't need. The record
types which OBJASM supports are listed below.
Record Type Type Name Description
----------- ----------- -----------------------------------
80h THEADR Module Header Record
88h COMENT Comment Record
8Ah MODEND End of Module Record
8Ch EXTDEF External Dependancy Definition
90h PUBDEF Public Value Definition
96h LNAMES List of Internally Referenced Names
98h GRPDEF Group Definition
9Ah SEGDEF Segment Definition
9Ch FIXUPP Dependancy Fixing-up Record
A0h LEDATA (Logically) Enumerated Data Record
A2h LIDATA (Logically) Iterated Data Record
B0h COMDEF Communal Value Definition
B4h LEXTDEF Local External Definitions (C static routines)
B6h LPUBDEF Local Public Definitions (??)
B7h LPUBDF2 Local Public Definitions (?? Another case? )
B8h LCOMDEF Local Communal Value Definitions (??)
The C modules which handle the records of the above formats are named by
placing the characters "OR" before the type name and have a .C extension.
For example, the module named "ORSEGDEF.C" contains the C routine to handle
the segment definition records.
INTEL defines these other record types which are not supported by OBJASM.
Record Type Type Name Description
----------- ----------- -----------------------------------
6Eh RHEADR R-Module Header Record
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -