Path: utzoo!utgpu!news-server.csri.toronto.edu!bonnie.concordia.ca!uunet!comp.vuw.ac.nz!actrix!templar!jbickers From: jbickers@templar.actrix.gen.nz (John Bickers) Newsgroups: comp.sys.amiga.programmer Subject: Re: How are some programs SO DAMN SMALL! Message-ID: <10571.tnews@templar.actrix.gen.nz> Date: 21 Jan 91 21:42:25 GMT References: <1991Jan20.210328.18087@hoss.unl.edu> Organization: TAP, NZAmigaUG. Lines: 65 Quoted from <1991Jan20.210328.18087@hoss.unl.edu> by 231b3678@fergvax.unl.edu (CS 231 section 2): > What are steps to compile the smallest Lattice code? Here are the few that I > know. Some more I've come across, mostly from a document John Toebes (sp?) wrote once... > 1) Use protos and include files whenever possible. If you don't need to your command line parsed, call your main() function _main(), or add this line to your BLINK WITH file: DEFINE __main=_main Otherwise, add this line to your BLINK WITH file: DEFINE __main=__tinymain In both cases use the XCEXIT() function in place of exit() throughout your program, and compile with -v for stack checking off. If you don't use the malloc() functions, and don't use floating point, you can also add this one: DEFINE _MemCleanup=___fpinit You also want to use the SC, SD, and ND options with blink. > Can 'C' code get small? I have a LIST program in the works. It's 14000 > bytes compared to c:list's 2500. Assembly must be the only decent way to Once you've done the above, a hello world sort of program has the bulk of its code in the c.o module you link with. #include #include #include void _main() { Write(Output(),"Hello World\n",12); } The next step is to drop the c.o altogether (I think Chuck... argh, can't remember the last name, mentioned this a while back), so you open whatever libraries you want (don't need Exec, but you may need AmigaDOS), etc, and link without c.o. #include #include #include #include struct Library *DOSBase; void foo() { DOSBase = OpenLibrary("dos.library",0L); Write(Output(),"Hello World\n",12); CloseLibrary(DOSBase); } This, or variations on this... > Phil Dietz -- *** John Bickers, TAP, NZAmigaUG. jbickers@templar.actrix.gen.nz *** *** "Patterns multiplying, re-direct our view" - Devo. ***