home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / lang / c / 19177 < prev    next >
Encoding:
Text File  |  1993-01-04  |  2.6 KB  |  67 lines

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