🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #8907

Re: The Most Compressed

#8907
From: Ed Mulroy [TeamB]
Date: Tue, 31 Aug 2004 12:27
112 lines
4552 bytes
You are correct.  These days you cannot buy a disk smaller than 
several Gig and cannot find memory that is smaller than 64M.  Other 
than for embedded work, the days of tiny storage sizes are long gone.

When memory and drive sizes were smaller I did this: 4096 byte EXE but 
only that big because I was too lazy to tell the linker to use a 
smaller minimum than 4K for its chunks.

-------------------
        .386p
        model flat

; build with these commands
; tasm32 /ml /l /zi helloasm
; ilink32 /Tpe/aa/Gn/x/c/v helloasm,,,import32

HWND_DESKTOP  equ  0
MB_OK                  equ  0

_TEXT   segment dword public use32 'CODE'
_TEXT   ends
_DATA   segment dword public use32 'DATA'
_DATA   ends
_BSS    segment dword public use32 'BSS'
_BSS    ends

; This program actually doesn't use _BSS
DGROUP  group   _BSS,_DATA

        extrn   MessageBoxA     :near

_DATA   segment dword public use32 'DATA'
        align   1
msg     db      " Hello World! ",0
mtitle  db      "Hello Message Box", 0
zero    dw      0
        align   4
_DATA   ends

_TEXT   segment dword public use32 'CODE'
WinMain proc    near
        push    ebp       ; save EBP and load stack ptr into it
        mov     ebp,esp

        ; MessageBox(HWND_DESKTOP, msg, "", MB_OK);
        push    MB_OK
        push    offset mtitle
        push    offset msg
        push    HWND_DESKTOP
        call    MessageBoxA

        xor     eax,eax  ; return value is zero
        pop     ebp      ; restore EBP register
        ret     16       ; return and free up 16 bytes of stack
WinMain endp
_TEXT   ends

        public  WinMain
        end     WinMain
------------------------------------

.  Ed

> Chris Croughton wrote in message
> news:slrncj8g2b.5g2.chris@ccserver.keris.net...
>
>> I personally think , It is possible to make a 1 Kilobytes exe
>> file to do a very simple job like Hello World !!
>
> Of course it is.  You don't need a Boeing 767 if you just want to 
> fly a
> kite.  I think my smallest program to output "Hello World" was about 
> 10
> bytes bigger than the string itself -- written all in hex.  But if 
> you
> are going to write a larger program, you will probably need all of 
> the
> other libraries, components, etc.
>
> If you are looking for a small "Hello World" program, there are 
> several
> ways to get it small.  For a start, do it as a console mode program
> rather than a GUI one:
>
>  #include <stdio.h>
>  int main(int argc, char **argv)
>  {
>    printf("Hello world!\n");
>    return 0;
>  }
>
> which will be far smaller.  Or if you really want to use the GUI, 
> use
> MessageBox (and omit including "dialogs.hpp").
>
> What do you /really/ want to do?  Trying to save a few bytes is 
> pretty
> pointless these days (that's not condoning bloat or sloppy 
> programming,
> but time to design and write an application in a clear and 
> maintainable
> fashion is more important than saving a few KB of disk or RAM 
> space).  I
> write mostly in C++, for instance, because although it is more
> 'expensive' in terms of space and (to a certain extent) speed the
> clarity is much improved, so the time spent won't have to be wasted
> later trying to work out what it did to maintain it.  I've seen 
> projects
> where they coded everything in assembler to save a few KB, and it 
> was
> hell trying to do something as simple as change the size of a 
> structure.
Technical Details
Message-ID: <41346eda@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <4130d6c2@newsgroups.borland.com> <4505j0d7fmr3dbl9fpabplhbpvv0gg50i5@4ax.com> <4133585a@newsgroups.borland.com> <slrncj8g2b.5g2.chris@ccserver.keris.net>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,8f88fecd49aea605
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Ed Mulroy [TeamB]" <dont_email_me@invalid.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4130d6c2@newsgroups.borland.com> <4505j0d7fmr3dbl9fpabplhbpvv0gg50i5@4ax.com> <4133585a@newsgroups.borland.com> <slrncj8g2b.5g2.chris@ccserver.keris.net>
Subject: Re: The Most Compressed
Date: Tue, 31 Aug 2004 08:27:43 -0400
Lines: 114
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
NNTP-Posting-Host: 12.161.27.49
Message-ID: <41346eda@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1093955290 12.161.27.49 (31 Aug 2004 05:28:10 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news2.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail