www.digitalmars.com Home | Search | CTG | RTL | IDDE | STL
Last update Sat Apr 8 23:54:06 2006
Compiler & Tools Guide

Compiling
Compiling Code
C Implementation
C++ Implementation
Language Extensions
Mixing Languages
Assembly Language
Inline Assembler
Optimizing Code
Numerics Programming
Regular Expressions
Acrtused
Pragmas
Precompiled Headers
Predefined Macros
Warning Messages
Error Messages
Runtime Messages


Linking
Optlink
Switches
Module Definition Files
Operation and Design
Error Messages


Win32 Programming
Win32 Programming


DOS and Win16
Programming

Memory Models
16 Bit Pointer Types
and Type Modifiers

Handle Pointers
DOS
DOS 32 (DOSX)
Win16
Win16 DLLs
Win16 Prolog/Epilog


C/C++ Extensions
Contract Programming
__debug statement
__debug declaration
Dynamic Profiling
Embedding C in HTML


Tools
BCC
CHMOD
CL
COFF2OMF
COFFIMPLIB
DMC
DIFF
DIFFDIR
DUMP
DUMPOBJ
DUMPEXE
EXE2BIN
FLPYIMG
GREP
HC
IMPLIB
LIB
LIBUNRES
MAKE
MAKEDEP
ME
OBJ2ASM
PATCHOBJ
RC
RCC
SC
SHELL
SMAKE
TOUCH
UNMANGLE
WHEREIS


Porting to DMC++
Switching to DMC++
from Microsoft
from Borland
Porting Guide


OBJ2ASM: Object File Disassembler

OBJ2ASM disassembles object (.obj) files in Intel OMF, Microsoft COFF format, or linux ELF format. (DMC++ generates Intel OMF format object files.) Looking at the assembly language output of the compiler is highly useful for:
  • Understanding how various language constructs are compiled.
  • Trying various ways of expressing an algorithm to see which ones produce faster code.
  • If a particular function needs to be rewritten in inline assembly and hand optimized for maximum speed, the OBJ2ASM output forms a good starting point.
  • Due to the large number of function calling conventions supported, sometimes it is necessary to verify that the correct convention is being used.
  • Verifying correct code generation.
  • Comparing output with other compilers.
  • Learning assembly language.

Compiling the file with the -gl option embeds line number information in the object file, enabling OBJ2ASM to match the source code up with the generated assembler instructions. Compiling the file with the -g option embeds debug records in the object file, which OBJ2ASM will format and output.

OBJ2ASM commands have the following format:

	obj2asm [-l -o -x] objectfile[.obj] [sourcefile] [-coutfile[.cod]]
objectfile is the object file to disassemble.
The extension defaults to .obj.
sourcefile is the file compiled to produce the object file.
Use this if the source file name embedded in the object file is missing or incorrect.
-l Omit code labels in the assembly language file it generates.
Useful when comparing two object files; helping highlight the differences between them.
-o Emit object code for each assembly language instruction.
-x Emit code segment offset for each instruction.
-coutfile Writes output to outfile instead of the standard output.
The default extension for outfile is .cod.
Example

To see the code generated by compiling test.cpp, use the following commands:

	dmc -c -gl test
	obj2asm test
Note: Although the output of OBJ2ASM is in MASM format, it usually requires a little editting before MASM will accept it.