News:

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

Small executables?

Started by Nezzari, July 04, 2006, 02:09:19 PM

Previous topic - Next topic

Nezzari

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?

hutch--

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

Nezzari

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.

hutch--

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

Vortex

Hi Hutch,

If I am not wrong, Masm 6.14 \ 6.15 is able to assemble 16-bit code.

hutch--

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