Path: utzoo!utgpu!cs.utexas.edu!swrinde!mips!apple!altos!vsi1!zorch!amiga0!mykes From: mykes@amiga0.SF-Bay.ORG (Mike Schwartz) Newsgroups: alt.sources.amiga Subject: Re: OS friendly assembly source examples Message-ID: Date: 2 May 91 22:54:02 GMT References: <1991Apr30.213936.22878@ux1.cso.uiuc.edu> Organization: Amiga makes it possible Lines: 46 In article <1991Apr30.213936.22878@ux1.cso.uiuc.edu> cs326ag@ux1.cso.uiuc.edu (Loren J. Rittle) writes: >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 > The size argument is based upon using printf() and not Write(). The program Loren posted is a good example of how to make a small 'C' program! Please note that I made zero attempts at optimizing for size or speed while Loren made every attempt. Also note that my post was not meant as a challenge, but just as an illustration of how you get smaller code WITHOUT trying. It was the most minimal program example, which K&R defines as: main() { printf("Hello, world\n"); } Of course, no offense taken. -- **************************************************** * I want games that look like Shadow of the Beast * * but play like Leisure Suit Larry. * ****************************************************