home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c
- Path: sparky!uunet!math.fu-berlin.de!news.th-darmstadt.de!rbg.informatik.th-darmstadt.de!misar
- From: misar@rbg.informatik.th-darmstadt.de (walter misar)
- Subject: Re: Followup on size of executables.
- Sender: news@news.th-darmstadt.de (The News System)
- Message-ID: <1993Jan4.122144@rbg.informatik.th-darmstadt.de>
- Date: Mon, 4 Jan 1993 11:21:44 GMT
- References: <93004.051358RVK@psuvm.psu.edu>
- Nntp-Posting-Host: rbhp87.rbg.informatik.th-darmstadt.de
- Organization: TH Darmstadt
- Lines: 54
-
- In article <93004.051358RVK@psuvm.psu.edu>, <RVK@psuvm.psu.edu> writes:
- > Thanks to everyone who replied to my earlier posting. I
- > feel, however, that I still need some more clarification.
- > I was asked what do I mean by a "huge" executable. The
- > phrase is perhaps inaccurate. I used it only in relative
- > terms, as illustrated by the example below.
- >
- > Consider the Hello, World example in assembly (for intel 486):
- >
- > .MODEL small
- > .STACK 100h
- > .DATA
- > CR EQU 13
- > LF EQU 10
- > EOS EQU '$'
- > HelloMessage DB 'Hello, World',CR,LF,EOS
- > ExitCode DB 0
- > .CODE
- > start:
- > mov ax,@data
- > mov ds,ax ;set DS to point to the data segment
- > mov ah,9 ;DOS print string function
- > mov dx,OFFSET HelloMessage ;point to 'Hello World'
- > int 21h ;display 'Hello, World'
- > mov ah,4ch ;DOS terminate program function
- > mov al,[ExitCode] ; Exit Code
- > int 21h ;terminate the program
- > END start
- >
- >
- > and consider the corresponding C fragment:
- >
- > #include <stdio.h>
- > int main() { printf("Hello, World\n"); return 0;}
- [ some stuff deleted ]
-
- Hm, I don't know about redirecting in MS-DOS, but C can't use int21 directly,
- since stdout may be some different file (could be at least freopened() ).
- If you're really concerned about size, why do you use the complex printf(),
- when a simple puts() will do ?
- Further, I don't think that #inluding <stdio.h> will cause the linker to
- add all functions prototyped therein, because the linklibraries aren't sorted
- according to header-files (on most systems) but roughly in standart-functions,
- math-functions and so on.
- Additionally C has to do a lot of startup-work before invoking main(), which
- adds to size too, like splitting the command line into args. After termination
- of the program, the implementation may choose to close all remaining unclosed
- files, or to free all memory malloced() but never freed(). All this convienience
- is paid with space of course, but on normal developments the impact isn't
- that great than on hello.c .
-
- --
- Walter Misar It is impossible to enjoy idling thoroughly
- misar@rbg.informatik.th-darmstadt.de unless one has plenty of work to do.
-