walker@unx.sas.com (Doug Walker) (10/11/90)
I posted a 'small' hello world program not too long ago in response to someone asking why hello world with printf() was so big... turns out there were SEVERAL bugs in even that small program. Here's a small hello world program that comes out to 124 bytes for me that does the job: ; /* ;EXECUTE THIS FILE AS A SHELL SCRIPT AND IT WILL COMPILE ITSELF lc -cwus -O -v -j73 hw blink from hw.o to hw sc sd quit */ #include <exec/types.h> #include <proto/exec.h> #include <proto/dos.h> void foo(void) { struct DosLibrary *DOSBase; if(DOSBase = OpenLibrary("dos.library", 0)) { Write(Output(), "Hello, World!\n", 15); CloseLibrary(DOSBase); } } A couple of things to note: 1. DOSBase is a local, not a global, because no startup code is used and thus A4 is not set up to point to the base of global storage. 2. The -cs option is REQUIRED for the same reason as (1) - with -cs, strings are stored in the code section and accessed PC-relative; otherwise, they are stored in the (nonexistent) data section. The "Hello, World!\n" string must be accessed PC-relative. 3. DOSBase is, of course, case-sensitive. 4. The -v option is necessary to avoid stack-checking code, which refers to external variables. ***** NOW AT 9600 DUAL STANDARD! =*|_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