Subj : Short executables
To   : Eddy Thilleman
From : David Noon
Date : Mon Jan 22 2001 12:55 pm

Hi Eddy,

Replying to a message of Eddy Thilleman to Murray Lesser:

ML>> My shortest such utility has a file length of 44 bytes and isn't
ML>> "self-modifying."

ET> Is this a contest of the shortest and smallest .COM file?? ;-)

Try this [I first posted this code in this echo back in 1998]:

=========================== HWORLD.ASM ================================
; OS/2 32-bit command line program. Sample of assembler code.
; Copyright: Public domain
          .486
          .MODEL FLAT,PASCAL

          .CONST
MsgText    DB     "Hello, World!"
MsgLen     EQU    $-MsgText

          EXTERN DosPutMessage: NEAR
STDOUT     EQU    1                    ; File handle for STDOUT: device

          .CODE
HelloWorld PROC   NEAR
          PUSH   EBP
          MOV    EBP,ESP

; Call DosPutMessage to display our message
          PUSH   OFFSET MsgText
          PUSH   MsgLen
          PUSH   STDOUT
          CALL   DosPutMessage
          ADD    ESP,12

; Clean stack area and return
          MOV    ESP,EBP
          POP    EBP
          RET
HelloWorld ENDP

          .STACK

          END    HelloWorld
=======================================================================

This program occupies 37 bytes plus its stack; as there are 4 DWORD PUSHes that
makes 53 bytes all up. You can reduce it further by outputting a shorter
message.

Another approach would be to change the memory model from FLAT to SMALL [after
all, this is a 32-bit, native OS/2 program] which will reduce the size of some
of the instructions. This is left to the student as an exercise. ... :-)

Regards

Dave
<Team PL/I>

--- FleetStreet 1.25.1
* Origin: My other computer is an IBM S/390 (2:257/609.5)