Path: utzoo!utgpu!cs.utexas.edu!uwm.edu!wuarchive!m.cs.uiuc.edu!ux1.cso.uiuc.edu!cs326ag From: cs326ag@ux1.cso.uiuc.edu (Loren J. Rittle) Newsgroups: alt.sources.amiga Subject: Re: OS friendly assembly source examples Message-ID: <1991Apr30.213936.22878@ux1.cso.uiuc.edu> Date: 30 Apr 91 21:39:36 GMT Organization: University of Illinois at Urbana Lines: 59 In article Mike (compilers suck :-) Schwartz (mykes@amiga0.SF-Bay.ORG) writes: >The second program is the ol' printf("Hello, world\n") >program done in assembly. I didn't comment the program >at all (who comments such a program :) and did not try >to squeeze it down as small as possible. I've never >seen a 'C' compiler even come close to 20 or 30 times >this executable size :) Well, you are now: Use `lc -. -v -cus hello.c >nil:' [-O does't help ;-] `blink from hello.o nd quiet' with SAS/C v5.0a (with 2.0 includes) to get an executable that is 124 bytes long... ...which is smaller than Mike's hand coded 180. :-) This may suprise a guy like Mike. :-) And, boy is the source more readable... :-) [Mike this was meant in good fun - ljr ;-] All joking aside, I hope everyone enjoys the `good', as in system friendly, asm code Mike posted. But don't use Mike's `size' statements as a good reason to code in asm instead of C! Thanks Mike! Sincerely, Loren ----- cut here (hello.c) ----- // Hello world in non-portable C // [non-portable because we call AmigaOS functions directly instead of // using the ANSI library and we use those snazzy C++ style comments. ;-] // // Programmed by Loren J. Rittle in more than 1 minute (but that is all it // would take next time :-). // // compiles and links into a 124 byte executable (62 byte codesize) // in .733 seconds (yes, Mike, I changed the time; that's all it took). // #include #include void hello (void) { struct ExecBase *SysBase = *((struct ExecBase **) (4)); struct DosLibrary *DOSBase; DOSBase = (struct DosLibrary *) OpenLibrary ("dos.library", 0); if (DOSBase) { Write (Output (), "Hello, world\n", 13); CloseLibrary ((struct Libaray *)DOSBase); } } ----- cut line (end of hello.c) ----- -- ``NewTek stated that the Toaster *would* *not* be made to directly support the Mac, at this point Sculley stormed out of the booth...'' --- A scene at the recent MacExpo. Gee, you wouldn't think that an Apple Exec would be so worried about one little Amiga device... Loren J. Rittle l-rittle@uiuc.edu