Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!mcnc!rti!mozart!walker From: walker@unx.sas.com (Doug Walker) Newsgroups: comp.sys.amiga.tech Subject: Re: Writing small code in SAS/C 5.10 Message-ID: <1990Oct01.212023.9242@unx.sas.com> Date: 1 Oct 90 21:20:23 GMT References: <13148@leadsv.UUCP> Organization: SAS Institute Inc. Lines: 47 In article <13148@leadsv.UUCP> lord@leadsv.UUCP (Parker Lord) writes: >I wrote myself a unix like 'mv' command because the AmigaDOS rename seemed >to limited. My problem is that the linked code comes out to be about 9K. >I used the SD SC ND flags with Blink. I thought that this was rather large >for the amount of code actually written so I tried a test. I wrote a one line >program that does nothing more than a printf("Hello\n"); I compiled and linked >this using lc -L. This code came out at about 4.6K. In comparison, the >AmigaDOS rename command is less than 1K and the ARP mv command is about 1K. >Are there some general guidelines to follow to make linked code smaller? >I also invoked the global optimizer with lc, but that didn't help at all. If you can do without stdin/stdout/stderr, I suggest using the __tinymain stuff in the compiler - see the manual for details. If you want to do even more, you can call your main routine _main instead of main and do without almost all of the C startup - if you do this, you won't get argc and argv as parameters, you'll get a pointer to the command line and that's it. Almost all of the overhead in the program you listed is due to this overhead. Try the following for a 132-byte program to do what yours does: #include #include struct DosLibrary *DOSBase; void foo(void) { DOSBase = OpenLibrary("dos.library", 0); Write(Output(), "Hello\n", 6); CloseLibrary(DOSBase); } Use the following to compile and link it: lc foo blink from foo.o to foo Note that you don't link with c.o, and you don't link with lc.lib or amiga.lib. ***** =*|_o_o|\\=====Doug Walker, Software Distiller====== BBS: (919)460-7430 = *|. o.| || | o |// For all you do, this bug's for you! ====== usenet: ...mcnc!rti!sas!walker plink: dwalker bix: djwalker