News:

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

Executable format under Windows

Started by P3t3, November 11, 2010, 11:38:02 PM

Previous topic - Next topic

P3t3

Hi,

New to 32-bit assembly programming. But did alot of 16-bit assembly in the days of DOS.
So getting into this whole 32-bit thing.

A simple question, which executable type do I build under Windows Vista/7 ?
Coff, PE?

And can someone simply explain them please.

Cheers

jj2007

#1
Welcome to the Forum :thumbu

You would typically use these commandlines:

\Masm32\bin\ml.exe /nologo /c /coff MyFile.asm

If you have resources:
  \masm32\bin\rc rsrc.rc

  With polink:
  \masm32\bin\polink.exe /SUBSYSTEM:WINDOWS MyFile.obj rsrc.res

  With link:
  \masm32\bin\cvtres /machine:ix86 rsrc.res
  \masm32\bin\link.exe /SUBSYSTEM:WINDOWS MyFile.obj rsrc.obj

If you do not have resources (assuming console app - could be WINDOWS, too):
  \masm32\bin\link.exe /SUBSYSTEM:CONSOLE MyFile.obj

COFF refers to the format produced by the assembler, i.e. *.obj
PE is the final format produced by the linker, i.e. *.exe

More at Microsoft or google for executable format coff PE.

Here are some tips, tricks and traps.

Hope this helps,
Jochen

EDIT: Corrected the linker command lines - polink accepts *.res, link doesn't.

dedndave

if you use the forum search tool, Hutch posted a PDF for version 8 of the PE spec
i had posted it long ago, but Hutch's file was a bit smaller

welcome to the forum   :U

hutch--

P3t3,

The basic are this, Win32 uses a "Portable Executable" format specific to Microsoft that has a DOS "MZ" header, usually referred to as the DOS stub followed by a PE (Portable Executable) header, a code or TEXT section that contains the executable code, a DATA section that contains initialised data and a resource section that contains things like bitmaps, icons, dialogs etc ....

The PE spec use a FLAT memory model that is a linear 32 bit address space and memory is addressed as 32 bit linear, there are no segment/offset based addressing in 32 bit PE. The base 32 bit PE works on every Windows version from Win95 OEM up to the 32 bit section of Win7 64 bit OS versions. DOS 16 bit real mode interrupts do not work in FLAT memory model 32 bit code (A few did in early win95) and you perform your OS based code using the Windows API functions instead.

The document to get from Microsoft is called PECOFF.DOCX which contains the 32 bit PE specifications.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

P3t3

Thanks heaps guys. That has helped.

I forgot to mention in my first post, how much I love assembly language.
I haven't code in x86 assembly since the early 90s.

Developing in high level languages over the years, just doesn't fill that void.
My passion is and always will be assembly language.

Vortex