Click to See Complete Forum and Search --> : Linker problem


Fatboy
December 20th, 2004, 01:52 PM
Problem with the masm32 linker.

I just wanted to test the masm32 assembler, my code couldn't be simpler:

dosseg
.model small
.stack 200h
.data
.code

start:
mov ax, 4c00h
int 21h
end start



This (called simple.asm) assembles fine, but f^*"s up on linking, I'll give you the compile log exactly as it appears in the command line:



c:\Secondary\masm32\BIN>ml simple.asm
Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997. All rights reserved.

Assembling: simple.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

/z2
"simple.obj"
"simple.exe"
NUL
LINK : warning LNK4044: unrecognised option "z2"; ignored
simple.obj : warning LNK4033: converting object format from OMF to COFF
simple.obj : warning LNK4078: multiple ".data" sections found with different attributes (C0220040)
LINK : fatal error LNK1181: cannot open input file "simple.exe"

c:\Secondary\masm23/BIN>






What did I do wrong? I'd really appreciate any help!

NoHero
December 20th, 2004, 02:13 PM
How do you call your linker?
I think this (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmasm/html/vclrfml.asp) page might be interesting to you.

Another point: Are you trying to compile 16bit code with a 32 bit assembler? If so you rather should use Netwide Assembler or Flat Assembler. They are more reliable than the Microsoft Assembler.

/ This is my 666 post :cool:. Hope Simon don't sees this. :D

Fatboy
December 20th, 2004, 03:06 PM
i'm afraid that didn't help, thanks anyway!

the nasm doesn't work either! It doesn't even assemble!

NoHero
December 20th, 2004, 03:09 PM
i'm afraid that didn't help, thanks anyway!

the nasm doesn't work either! It doesn't even assemble!

nasm simple.asm -o simple.exe

Worked for me! :wave:. It creates a flat exe (.com, .bin) if you want other object files to be created use the -f command line option.
Yes it does assemble but everything runs in the background

for example:
nasm simple.asm -o simple.obj -f win32

Now you can give this another linker as input to create a 32 bit windows application. But to get this work you need additional modifcations in your source code:


[Bits 32]


This directive shows the assembler to create 32 bit application. It this case you should use eax instead of ax. A 32bit application does not support any dos or bios interrupts. So I think a 16bit dos application is the right for you.

Fatboy
December 20th, 2004, 03:48 PM
Which nasm assembler did you use?
Can you tell me the ftp URL?
Thanks

NoHero
December 21st, 2004, 08:25 AM
http://nasm.sourceforge.net

I use the Win32 compilat.

Fatboy
December 21st, 2004, 02:31 PM
Is there absolutely no way of assembling it with masm32? By twiddling with some linker options?


Is there a place I can download the tasm assembler from?

NoHero
December 21st, 2004, 02:36 PM
Is there absolutely no way of assembling it with masm32? By twiddling with some linker options?

For shure you could use MASM32. But I have never worked with it. And you might search the MSDN for some command line options. Sorry for forcing you to use nasm, but I really appreciate this compiler with its high level of compatibility and simpliness.

Is there a place I can download the tasm assembler from?

Take a look at the following FAQ (http://www.codeguru.com/forum/showthread.php?t=306905)
:cool:

/ Like Andreas ... :D

Fatboy
December 21st, 2004, 04:07 PM
Nope, still can't find tasm

See, I tried nasm, it just doesn't even assemble! At least masm32 assembles it into an obj file! Nasm always gives something like:

parser: instruction expected

I don't know what that means.

NoHero
December 22nd, 2004, 08:52 AM
Of course you cannot use the following instructions in nasm:


dosseg
.model small
.stack 200h
.data
.code


This is not legal in nasm, because these directives are compiler dependend. Try to search through the NASM help for similar directives.
TASM (http://www.freepgs.com/bboard/data/flo/tasm.zip)

rxbagain
December 23rd, 2004, 08:56 PM
Use MASM with DOS support. Go to THIS SITE (http://www.angelfire.com/linux/cdude/) and download MASM 6.11.

I Compiled ur code like this (simple.asm is in C:\MASM611 folder)
C:\MASM611>bin\ml /c simple.asm
Microsoft (R) Macro Assembler Version 6.11
Copyright (C) Microsoft Corp 1981-1993. All rights reserved.

Assembling: simple.asm

C:\MASM611>binr\link simple.obj,,,,,

Microsoft (R) Segmented Executable Linker Version 5.31.009 Jul 13 1992
Copyright (C) Microsoft Corp 1984-1992. All rights reserved.


Hope it will help you

Fatboy
December 24th, 2004, 04:43 PM
What's the five commas after simple.obj for? And why \binr? Why the "r"? I don't have a folder called binr. So all in all, it still doesn't assemble.

You guys, I really appreciate your help by the way, thank a lot!

rxbagain
December 24th, 2004, 10:42 PM
You have to install it with the DOS/Windows & NT to get the binaries for DOS (BINR folder).

The commas I used mean that I did not specify values for exefile, mapfile, libs, deffile and it will use default values if necessary.

Hope it will help you.