The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: johnsa on October 09, 2007, 11:50:36 AM

Title: Using Masm 6+ with a different linker
Post by: johnsa on October 09, 2007, 11:50:36 AM
Hi all,

I'm working on an OS project (purely for fun) I've used my original legit copies of tasm/tlink to produce the various realmode libs and primary and secondary stage bootcode / kernel loaders. Now that everything is up and running and about to switch to 32bit pmode I would much rather write the code using the latest masm package to allow me to code the kernel to make use of mmx/sse(2) etc without needing huge amounts of macros. Problem is that tlink can't link the obj files produced by masm and ms link can't produce flat binaries with all the relocation stuff.

I literally want a flat binary file with all offsets 0-relative to the beginning of the file.
I've heard that LD (gnu linker) would be an option, but I'm not sure if a) this works with masm and b) where the heck to find the win32 binary for it.

Any help would be great!
Thanks
John
Title: Re: Using Masm 6+ with a different linker
Post by: hutch-- on October 09, 2007, 11:53:59 AM
John,

Have a good look at either FASM or NASM, FASM being better supported. It can rountinely create flat binary files of the type you need for hobby OS development.
Title: Re: Using Masm 6+ with a different linker
Post by: sinsi on October 09, 2007, 11:56:13 AM
I've also tried the "roll your own" OS path and you can't go past FASM for that kind of stuff.
http://flatassembler.net/

edit: damn, hutch is quick for an old fart ain't he... :(
Title: Re: Using Masm 6+ with a different linker
Post by: johnsa on October 09, 2007, 11:57:39 AM
Thanks!

Would it be possible to use the ml assembler, and then just link it with the fasm package?
I've never been to keen on the other asm's, especially that funny at&t syntax in nasm (i believe that's what it is).
Title: Re: Using Masm 6+ with a different linker
Post by: sinsi on October 09, 2007, 12:06:01 PM
I'm a diehard "macro? what's that crap" masm programmer and found the syntax of FASM easier to swallow than NASM, but that's my opinion.
Once you get beyond the differences from MASM it makes a bit more sense. And it's great for any type of binary file e.g. the "org 0x7c00" stuff.

As far as linking etc., FASM is an all-in-one assembler+linker and won't let you link OBJ files - although you can produce a COFF in FASM.
Title: Re: Using Masm 6+ with a different linker
Post by: Mark Jones on October 09, 2007, 02:52:23 PM
Quote from: johnsa on October 09, 2007, 11:57:39 AM
Would it be possible to use the ml assembler, and then just link it with the fasm package?

Well this may be possible, but the MASM license dictates that code assembled with ml.exe must be only built and ran on Windows. This is why so many "competitor" assemblers have sprung up such as GoAsm and PoAsm.

Another (EMF) assembler like TASM is LzAsm - check it out: http://lzasm.hotbox.ru/

Edit: clarification.
Title: Re: Using Masm 6+ with a different linker
Post by: Vortex on October 09, 2007, 05:40:32 PM
Hi John,

The linker ld.exe can link MASM object files but I cannot guarantee it will work always. The MinGW tools are using a different version of COFF, this can be a problem while ld.exe handles the MS COFF relocation info.

ld.exe is a component of MinGW binutils package :

http://sourceforge.net/project/showfiles.php?group_id=2435

Attached is a MASM demo linked with MinGW ld.exe :

\masm32\bin\ml /c /coff Dialog.asm
\goasm\gorc /o Rsrc.rc
ld -e_start -subsystem windows -Lc:\masm32\lib -o Dialog.exe Dialog.obj Rsrc.obj -luser32 -lkernel32 -s



[attachment deleted by admin]