• Short executables

    From David Noon@2:257/609.5 to Eddy Thilleman on Monday, January 22, 2001 12:55:34
    Hi Eddy,

    Replying to a message of Eddy Thilleman to Murray Lesser:

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

    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)
  • From Eddy Thilleman@2:280/5143.7 to David Noon on Thursday, January 25, 2001 12:41:31
    Hello David,

    Monday 22 January 2001 20:55, David Noon wrote to Eddy Thilleman:

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

    HWORLD.ASM OS/2 32-bit command line program.

    Hmm, maybe I'll try to assemble this, does TASM do the job? I don't have a real
    OS/2 assembler, where would I find a decent one? I can vaguely remember ALP, does that ring a bell?

    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. ... :-)

    Yet another approach would be to do it in REXX or in a batch file, they have the same functionality (display a small message) and are smaller. ;-))


    Greetings -=Eddy=-

    email: e.thilleman@freeler.nl
    e.thilleman@hccnet.nl

    ... Get gun, shoot computer, turn off lights, go to bed, sigh
    --- GoldED/2 3.0.1
    * Origin: _REAL_ programmers use COPY CON PROGRAM.ZIP (2:280/5143.7)
  • From David Noon@2:257/609.5 to Eddy Thilleman on Monday, January 29, 2001 12:58:46
    Hi Eddy,

    Replying to a message of Eddy Thilleman to David Noon:

    HWORLD.ASM OS/2 32-bit command line program.

    Hmm, maybe I'll try to assemble this, does TASM do the job?

    That depends on which TASM you have. If it supports .MODEL FLAT then you are in
    luck. Just remeber to link the object code using LINK386.EXE or ILINK.EXE.

    I don't
    have a real OS/2 assembler, where would I find a decent one? I can
    vaguely remember ALP, does that ring a bell?

    ALP is the IBM assembler for OS/2. It is bundled with the OS/2 Warp Developer's
    Toolkit 4.0 and the OS/2 Device Driver Kit 4.0. The latter can be downloaded from one of IBM's Web sites.

    If you can find a copy of Watcom C/C++ then you will get a copy of WASM, which is also an OS/2 assembler. Just be aware that the Watcom linker was very flakey
    in the 11.0 releases, but quite good in the 10.x releases.

    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. ... :-)

    Yet another approach would be to do it in REXX or in a batch file,
    they have the same functionality (display a small message) and are smaller. ;-))

    But that requires that the command shell and, in the former case, REXX interpreter be loaded, so its memory footprint is a couple of hundred kilobytes
    larger.

    Regards

    Dave
    <Team PL/I>

    --- FleetStreet 1.25.1
    * Origin: My other computer is an IBM S/390 (2:257/609.5)
  • From David Noon@2:257/609.5 to Eddy Thilleman on Wednesday, January 31, 2001 10:54:36
    Hi Eddy,

    Replying to a message of Eddy Thilleman to David Noon:

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

    HWORLD.ASM OS/2 32-bit command line program.

    Hmm, maybe I'll try to assemble this, does TASM do the job?

    Try this one, if your TASM does only 16-bit code. Just remember to link it with
    OS/2's LINK.EXE and use OS2.LIB from the OS/2 Developer's Toolkit 1.3 [although
    OS2386.LIB in the later DTK's also contains the 16-bit imports, I think].

    ========================== HWORLD16.ASM ============================
    ; OS/2 16-bit command line program. Sample of assembler code.
    ; Copyright: Public domain
    .286
    .MODEL SMALL,PASCAL

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

    EXTERN VioWrtTTY: FAR

    .CODE
    HelloWorld PROC NEAR
    PUSH BP
    MOV BP,SP

    ; Call VioWrtTTY to display our message
    PUSH SEG MsgText
    PUSH OFFSET MsgText
    PUSH MsgLen
    PUSH 0
    CALL VioWrtTTY

    ; Clean stack area and return
    MOV SP,BP
    POP BP
    RET
    HelloWorld ENDP

    .STACK

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

    It works out a couple of bytes smaller than the 32-bit program I posted before [44 bytes, compared to 53 bytes]. This is like counting archangels on the head of a pin.

    Regards

    Dave
    <Team PL/I>

    --- FleetStreet 1.25.1
    * Origin: My other computer is an IBM S/390 (2:257/609.5)
  • From Eddy Thilleman@2:280/5143.7 to David Noon on Thursday, February 01, 2001 12:48:38
    Hello David,

    Monday 29 January 2001 20:58, David Noon wrote to Eddy Thilleman:

    Hmm, maybe I'll try to assemble this, does TASM do the job?

    That depends on which TASM you have. If it supports .MODEL FLAT then
    you are in luck.

    No, it doesn't, but then again it's only the DOS version. I've some version of a Borland C for OS/2 on floppy, but I don't have time for that.

    I don't have a real OS/2 assembler, where would I find a decent one?
    I can vaguely remember ALP, does that ring a bell?

    ALP is the IBM assembler for OS/2. It is bundled with the OS/2 Warp Developer's Toolkit 4.0 and the OS/2 Device Driver Kit 4.0. The latter
    can be downloaded from one of IBM's Web sites.

    I can barely keep up with the messages.

    Yet another approach would be to do it in REXX or in a batch
    file, they have the same functionality (display a small message)
    and are smaller. ;-))

    But that requires that the command shell and, in the former case, REXX interpreter be loaded, so its memory footprint is a couple of hundred kilobytes larger.

    O yes, that's true. :)


    Greetings -=Eddy=-

    email: e.thilleman@freeler.nl
    e.thilleman@hccnet.nl

    ... Brace for impact, Picard said parenthetically.
    --- GoldED/2 3.0.1
    * Origin: Unable to open Windows. Try the door? [Y]/N (2:280/5143.7)
  • From Eddy Thilleman@2:280/5143.7 to David Noon on Saturday, February 03, 2001 06:30:44
    Hello David,

    Wednesday 31 January 2001 18:54, David Noon wrote to Eddy Thilleman:

    Try this one, if your TASM does only 16-bit code. Just remember to
    link it with OS/2's LINK.EXE and use OS2.LIB from the OS/2 Developer's Toolkit 1.3 [although OS2386.LIB in the later DTK's also contains the 16-bit imports, I think].

    I found LINK.EXE, but I didn't find OS2.LIB and I don't have one of the OS/2 DTK's (maybe I could download one, but I don't have the time anyway).

    This is like counting archangels on the head of a pin.

    I agree. :)


    Greetings -=Eddy=-

    email: e.thilleman@freeler.nl
    e.thilleman@hccnet.nl

    ... General Failure reading drive A: Please remove your fist
    --- GoldED/2 3.0.1
    * Origin: Pakled DOS: We look for things to make us .EXE. (2:280/5143.7)