News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Using Masm 6+ with a different linker

Started by johnsa, October 09, 2007, 11:50:36 AM

Previous topic - Next topic

johnsa

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

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

sinsi

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... :(
Light travels faster than sound, that's why some people seem bright until you hear them.

johnsa

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).

sinsi

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.
Light travels faster than sound, that's why some people seem bright until you hear them.

Mark Jones

#5
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.
"To deny our impulses... foolish; to revel in them, chaos." MCJ 2003.08

Vortex

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]