I am having problems with the masm linker when it builds the exe most of the file is zeros. when i dissasimble the exe there is only 17 bytes of command data but the file is 512 the code offset is 200h evereyting between 10h and 200h is zero any ideas why??
Posted on 2004-09-01 18:27:08 by inuyaga
This is the case with procedures built as COFF modules in PE files. The EXE file will always be multiples of 512 or larger so if you have truly tiny code, the rest of the code section is padded out with zeros.

The first section usually contains the MZ dos header, the PE header and the section headers.

You can be satisfied with this much that if you add a 50 byte procedure to your exe, all you get is the 50 bytes in the code section. With default format MASM, the library code is added after the jump table at the end so its easy to check.
Posted on 2004-09-01 19:04:04 by hutch--
ok that sounds logical but is there a way around i need this to fit in a single sector. namley the boot sector. is there a way this can be done
Posted on 2004-09-01 21:32:05 by inuyaga
Microsoft has written all their OS bootsectors in MASM, but IMO if you need this kind of stuff, you're better off with FASM or NASM, as they have direct binary output etc.
Posted on 2004-09-02 00:41:07 by f0dder
Boot sectors are almost exclusively 16 bit real mode code so you would need to use a 16 bit linker with ML to write one. Most assemblers can still write 16 bit code so its not a difficult task.


hutch at movsd dot com
Posted on 2004-09-02 03:11:25 by hutch--