Path: utzoo!utgpu!cs.utexas.edu!wuarchive!usc!snorkelwacker.mit.edu!stanford.edu!neon.Stanford.EDU!flamingo.Stanford.EDU!espie From: espie@flamingo.Stanford.EDU (Marc Espie) Newsgroups: alt.sources.amiga Subject: Re: Short Hello World Message-ID: <1991May4.005624.7301@neon.Stanford.EDU> Date: 4 May 91 00:56:24 GMT References: <1991May2.102554.8679@cs.umu.se> <1200@cbmger.UUCP> <21231@cbmvax.commodore.com> Sender: news@neon.Stanford.EDU (USENET News System) Organization: LIENS, ENS, 45 rue d'Ulm, Paris (France) Lines: 66 In article <21231@cbmvax.commodore.com> bj@cbmvax.commodore.com (Brian Jackson) writes: >In article <1200@cbmger.UUCP> peterk@cbmger.UUCP (Peter Kittel GERMANY) writes: >>In article <1991May2.102554.8679@cs.umu.se> dvljrt@cs.umu.se (Joakim Rosqvist) writes: >>>>with SAS/C v5.0a (with 2.0 includes) to get an executable that is >>>>// >>>>// compiles and links into a 124 byte executable (62 byte codesize) >>> >>>Ok, assembler strikes back with this: (56 codesize, 92 executable) >>> >>>OpenLib=-408 >>>Output=-60 >>>Write=-48 >> >>Shame on you, you cheated! You do an OpenLib without a CloseLib! >>Perhaps this explains the difference. > >Not to mention absolutely no error checking. Hard to consider it >a "fully compliant" answer to the problem. The question should be >"how small can you make a -correct- 'hello world' ?" > >>Best regards, Dr. Peter Kittel // E-Mail to \\ Only my personal opinions... >>Commodore Frankfurt, Germany \X/ {uunet|pyramid|rutgers}!cbmvax!cbmger!peterk > >bj > > ----------------------------------------------------------------------- > | Brian Jackson Software Engineer, Commodore-Amiga Inc. GEnie: B.J. | > | bj@cbmvax.cbm.commodore.com or ...{uunet|rutgers}!cbmvax!bj | > | "We defy augury" | > ----------------------------------------------------------------------- So far, neither the C nor the C hello world programs are correct, they do not check for their environment and crash when started from workbench... I would say that the C program is a little less flawed. (you MUST check for the environment, even if you don't want to deal with the workbench, you should AT LEAST exit politely when started from workbench.) The code to do that looks like this: ----------------------- t = FindTask(0L); if (!t->pr_CLI) { /* started from Workbench. * you MUST execute the following code BEFORE opening DOS... */ while (!StartupMsg = GetMsg(t->pr_MsgPort)) WaitPort(t->pr_MsgPort); } /* do whatever you want... don't forget to close the DOS library */ /* clean exit code */ if (!t->pr_CLI) { /* don't forget the Forbid(), or Workbench might unload us before * we're through... */ Forbid(); ReplyMsg(StartupMsg); } /* fall through the end of code, don't Disable(), this * is the only case where you don't pair Forbid()/Disable(). */ ------------------------ Write code that doesn't crash under Workbench and I'll write code that works under 1.3, ok ? (For further reference, check for instance the RKM (libr & devices) 1.3, Workbench chapter. --- Marc Espie (espie@flamingo.stanford.edu)