Copyright (C) 2000-2012 |
GNU Info (nasm.info)Section 7.2.27.2.2. Using the `obj' Format To Generate `.COM' Files ------------------------------------------------------ If you are writing a `.COM' program as more than one module, you may wish to assemble several `.OBJ' files and link them together into a `.COM' program. You can do this, provided you have a linker capable of outputting `.COM' files directly (TLINK does this), or alternatively a converter program such as `EXE2BIN' to transform the `.EXE' file output from the linker into a `.COM' file. If you do this, you need to take care of several things: * The first object file containing code should start its code segment with a line like `RESB 100h'. This is to ensure that the code begins at offset `100h' relative to the beginning of the code segment, so that the linker or converter program does not have to adjust address references within the file when generating the `.COM' file. Other assemblers use an `ORG' directive for this purpose, but `ORG' in NASM is a format-specific directive to the `bin' output format, and does not mean the same thing as it does in MASM-compatible assemblers. * You don't need to define a stack segment. * All your segments should be in the same group, so that every time your code or data references a symbol offset, all offsets are relative to the same segment base. This is because, when a `.COM' file is loaded, all the segment registers contain the same value. automatically generated by info2www version 1.2.2.9 |