home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Programming / C / SASC6571.LZX / examples / nostartup / READ.ME < prev   
Encoding:
Text File  |  1996-12-24  |  3.2 KB  |  69 lines

  1. Copyright (c) 1993 SAS Institute, Inc, Cary, NC USA
  2. All Rights Reserved
  3.  
  4. Startup Code - What is it?
  5. --------------------------
  6.  
  7. When you create a program, you put together statements to tell the computer
  8. what to do.  Then the compiler turns those statements into executable code
  9. to do what you wished.
  10.  
  11. The startup code (c.o, cres.o, cback.o, etc.) does the initial work so that
  12. C statements such as
  13.  
  14.     printf("Hello, World!");
  15.  
  16. will work.  Without this code, you would need to do the set up yourself, in
  17. every program you write.
  18.  
  19.  
  20. Why would I NOT want to use the standard Startup Code?
  21. ------------------------------------------------------
  22.  
  23. While it is nice that this code sets things up for you, it really does a lot
  24. more than is necessary on the Amiga.  It does allow you to take programs
  25. from other computers and make them run on the Amiga with a minimum of
  26. effort, but your program is generally larger than it needs to be.  This is
  27. usually the case when using generic code (such as the startup code), as
  28. opposed to customizing your code to the specific application.  For instance,
  29. how many times have you used the "stderr" stream, except for occasional
  30. error message printing?  With the standard startup code, "stderr" is always
  31. initialized, whether you use it or not.
  32.  
  33. If you are planning on 'porting (a term used to mean placing the same code
  34. on different machines, and making it run) your code to another computer,
  35. then you are better off using the standard startup.  It will be easier to
  36. make it work on the other machine that way.
  37.  
  38. However, if your program is only meant for the Amiga, or you would have to
  39. do a significant amount of work to change it for the other platform anyway,
  40. there is no reason NOT to make it Amiga specific, and bypass the overhead of
  41. the standard startup code.
  42.  
  43.  
  44. How do I write a program that doesn't need Startup Code?
  45. --------------------------------------------------------
  46.  
  47. First, look at the program in the "Example_1" drawer of this directory.  It
  48. is an example of the fairly classic "Hello, World!" program given in many
  49. programming books and classes.    It has been compiled with every option
  50. which can reduce the code size, and the resultant program is still 4132
  51. bytes in size.
  52.  
  53. Now, look at the program in the "Example_2" drawer.  It is linked with no
  54. Startup Code at all, which gives the smallest possible program.  All it
  55. will contain is the code necessary to execute the program, with no extra
  56. setup of unnecessary details.  All the work is done in the program itself.
  57. The down side of not using any Startup Code is that NOTHING is done for
  58. you, you must do EVERYTHING yourself.  This is not as bad as it seems,
  59. since there is really very little to do for this program.  Even with
  60. having to open all the correct libraries ourselves, and doing the direct
  61. calls to AmigaDOS, the entire program, which performs the exact same
  62. functions as the first one, is only 124 bytes in size!
  63.  
  64. Last, but not least, the program in the "Example_3" drawer is AmigaDOS
  65. V2.0 specific code, showing how easy it is to do a complete, useful
  66. program, with full command-line parsing, wildcard handling, etc.  It is
  67. similar to the UNIX 'cat' command (which displays text files on the
  68. screen), and its only 568 bytes in size!
  69.