The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: Nezzari on July 04, 2006, 02:09:19 PM

Title: Small executables?
Post by: Nezzari on July 04, 2006, 02:09:19 PM
In Nasm I was able to make a small program (that simply printed out a sentence) in under 40 bytes. On MASM a program like that seems to take 1 kb... Is there a way to reduce the size of the .exe?
Title: Re: Small executables?
Post by: hutch-- on July 04, 2006, 02:12:30 PM
Yes, write a DOS COM file in MASM. To compare the two assembler, write the same type of code, COM or MZ style EXE for DOS or in 32 bit, a PE spec file which is 1k or larger.

Here is a 15 byte MASM COM file. You could get it a bit smaller if you could be bothered.


com_seg segment byte public         ; define the ONLY segment

    assume cs:com_seg, ds:com_seg   ; both code & data in same segment.
    org 100h                        ; go to start adress in memory.

start:
    mov ah, 09h
    mov dx, OFFSET hi
    int 21h                         ; call DOS to display the text.

    mov ax, 4Ch                     ; the TERMINATE process function.
    int 21h                         ; call DOS again to EXIT.

    hi db "hi$"

com_seg ends                        ; define the end of the segment.

    end start


The build environment used here is the 1993 version of MASM 6.11.
Title: Re: Small executables?
Post by: Nezzari on July 04, 2006, 02:35:21 PM
Thanks hutch--, that's what I was asking. I guess I'm just a little confused. There seems to be different ways of programming in ASM. Some seem to be "higher" than others.

Doesn't seem to link but that's okay.
Title: Re: Small executables?
Post by: hutch-- on July 04, 2006, 02:51:09 PM
You need MASM 6.11 release from 1993 to build it as it is. If you looked up the OMF linker options from the old style linker you could link it that way.
Title: Re: Small executables?
Post by: Vortex on July 04, 2006, 04:59:00 PM
Hi Hutch,

If I am not wrong, Masm 6.14 \ 6.15 is able to assemble 16-bit code.
Title: Re: Small executables?
Post by: hutch-- on July 05, 2006, 08:34:48 AM
Erol,

You are right but you need the linker as well from 16 bit OMF. The code I posted was a quickly put together demo written in the PWB in MASM 6.11 and I had to set the build target to get a COM file.