GNU Info

Info Node: (nasm.info)Section 6.2

(nasm.info)Section 6.2


Next: Section 6.2.1 Prev: Section 6.1.4 Up: Chapter 6
Enter node , (file) or (file)node

6.2. `obj': Microsoft OMF Object Files
======================================

   The `obj' file format (NASM calls it `obj' rather than `omf' for
historical reasons) is the one produced by MASM and TASM, which is
typically fed to 16-bit DOS linkers to produce `.EXE' files. It is also
the format used by OS/2.

   `obj' provides a default output file-name extension of `.obj'.

   `obj' is not exclusively a 16-bit format, though: NASM has full
support for the 32-bit extensions to the format. In particular, 32-bit
`obj' format files are used by Borland's Win32 compilers, instead of
using Microsoft's newer `win32' object file format.

   The `obj' format does not define any special segment names: you can
call your segments anything you like. Typical names for segments in
`obj' format files are `CODE', `DATA' and `BSS'.

   If your source file contains code before specifying an explicit
`SEGMENT' directive, then NASM will invent its own segment called
`__NASMDEFSEG' for you.

   When you define a segment in an `obj' file, NASM defines the segment
name as a symbol as well, so that you can access the segment address of
the segment. So, for example:

     segment data
     
     dvar:   dw      1234
     
     segment code
     
     function:
             mov     ax,data         ; get segment address of data
             mov     ds,ax           ; and move it into DS
             inc     word [dvar]     ; now this reference will work
             ret

   The `obj' format also enables the use of the `SEG' and `WRT'
operators, so that you can write code which does things like

     extern  foo
     
           mov   ax,seg foo            ; get preferred segment of foo
           mov   ds,ax
           mov   ax,data               ; a different segment
           mov   es,ax
           mov   ax,[ds:foo]           ; this accesses `foo'
           mov   [es:foo wrt data],bx  ; so does this

Section 6.2.1
`obj' Extensions to the `SEGMENT' Directive
Section 6.2.2
`GROUP': Defining Groups of Segments
Section 6.2.3
`UPPERCASE': Disabling Case Sensitivity in Output
Section 6.2.4
`IMPORT': Importing DLL Symbols
Section 6.2.5
`EXPORT': Exporting DLL Symbols
Section 6.2.6
`..start': Defining the Program Entry Point
Section 6.2.7
`obj' Extensions to the `EXTERN' Directive
Section 6.2.8
`obj' Extensions to the `COMMON' Directive

automatically generated by info2www version 1.2.2.9