News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Combining segments by Linker

Started by arka.sharma, September 28, 2015, 05:32:51 PM

Previous topic - Next topic

arka.sharma

Hi All,

I am using MASM6.1 for 3 months and I am referring to the MASM Programming Guide that came with the installation under "doc" folder. I am not a experienced assembly programmer so I have lot of doubts regarding it. MASM Programming Guide
QuoteWithin a module, all segment definitions with the same name are treated as though they reference the same segment. The linker also combines identically named segments from different modules unless the combine type is PRIVATE.
. Now let say I am having two files A.asm and B.asm. and following is the segment definition for A and B respectively _TEXT SEGMENT WORD PUBLIC 'CODE' and _TEXT SEGMENT PARA PUBLIC 'CODE'. and the linking order is as such ml A.obj B.obj So while combining how the alignment will be done. Because it sounds to me that _TEXT refers the same segment so how they are aligned while combining ? I apologize if the question is stupid.

Regards,
Arka

dedndave

first, let me say that you are reading an outdated book
in the world of 16-bit code, we used to define our own segments if we wanted ultimate control over them

the 16-bit memory models are "segmented"
that's because a 16-bit address can access only 64 Kb without changing a segment register
if you want 2 segments to combine, they should have the same attributes

in 32-bit code, microsoft uses a "flat" memory model
and, while there are still different sections, the segment registers are now used as "selectors"
a 32-bit address can access 4 Gb without changing anything   :biggrin:
code, data, stack, everything in one "segment"
in fact, we rarely mess with the segment registers, at all

dedndave

i should also mention....

masm v 6.x may be used for either 16-bit or 32-bit code
however, you must use a 16-bit linker for 16-bit code
and a 32-bit linker for 32-bit code

also, 16-bit OBJ files used the OMF format
and 32-bit OBJ files use the COFF format

so, when assembling 16-bit code with masm, use the /omf switch (coff is the default)
we also use the /c switch to prevent masm from linking the result
this allows you to use a different linker

ml /c /omf MyFile16.asm

FORTRANS

Hi,

   Generate an assembler listing and cross reference, and make
a linker map to answer your question.  Or disassemble the OBJ
file to find out.  Or debug the program for an answer as to what
the linker created.

Regards,

Steve N.

arka.sharma

Quoteso, when assembling 16-bit code with masm, use the /omf switch (coff is the default)
we also use the /c switch to prevent masm from linking the result
this allows you to use a different linker

I have searched in MASM 6.1 reference. I couldn't find any /omf option.
For linking I am using

ml.exe A.obj B.obj C.obj

I don't know which linker is internally invoked.

dedndave

C:\Documents and Settings\Dave\Desktop => ml/?
Microsoft (R) Macro Assembler Version 6.15.8804
Copyright (C) Microsoft Corp 1981-2000.  All rights reserved.


        ML [ /options ] filelist [ /link linkoptions ]

/AT Enable tiny model (.COM file)         /omf generate OMF format object file
/Bl<linker> Use alternate linker          /Sa Maximize source listing
/c Assemble without linking               /Sc Generate timings in listing
/Cp Preserve case of user identifiers     /Sf Generate first pass listing
/Cu Map all identifiers to upper case     /Sl<width> Set line width
/Cx Preserve case in publics, externs     /Sn Suppress symbol-table listing
/coff generate COFF format object file    /Sp<length> Set page length
/D<name>[=text] Define text macro         /Ss<string> Set subtitle
/EP Output preprocessed listing to stdout /St<string> Set title
/F <hex> Set stack size (bytes)           /Sx List false conditionals
/Fe<file> Name executable                 /Ta<file> Assemble non-.ASM file
/Fl[file] Generate listing                /w Same as /W0 /WX
/Fm[file] Generate map                    /WX Treat warnings as errors
/Fo<file> Name object file                /W<number> Set warning level
/FPi Generate 80x87 emulator encoding     /X Ignore INCLUDE environment path
/Fr[file] Generate limited browser info   /Zd Add line number debug info
/FR[file] Generate full browser info      /Zf Make all symbols public
/G<c|d|z> Use Pascal, C, or Stdcall calls /Zi Add symbolic debug info
/H<number> Set max external name length   /Zm Enable MASM 5.10 compatibility
/I<name> Add include path                 /Zp[n] Set structure alignment
/link <linker options and libraries>      /Zs Perform syntax check only
/nologo Suppress copyright message

C:\Documents and Settings\Dave\Desktop =>


notice that the /c and /omf switches are lower case - it may be case sensitive, not sure
for some MS command-line programs, it's "/help" to get the list

arka.sharma

Thanks for your reply. Actually I am having an older version than you. Mine is 6.11.

dedndave

i believe the masm32 package comes with version 6.14
i don't think i've ever used 6.11   :biggrin:

i have used versions 3, 4, and 5.1 though - lol