Path: utzoo!utgpu!cs.utexas.edu!swrinde!mips!apple!fernwood!uupsi!sunic!cs.umu.se!dvljrt From: dvljrt@cs.umu.se (Joakim Rosqvist) Newsgroups: alt.sources.amiga Subject: Re: Short Hello World Message-ID: <1991May5.134657.27696@cs.umu.se> Date: 5 May 91 13:46:57 GMT References: <1991May2.102554.8679@cs.umu.se> <1991May5.011748.11595@zorch.SF-Bay.ORG> Sender: news@cs.umu.se (News Administrator) Organization: Dep. of Info.Proc, Umea Univ., Sweden Lines: 67 >Here's the right way, and NO HLL has any automatic anything over this. >It is 12 bytes shorter than the best 'C' equivilent (so far) and is >also 10% faster (clock cycles). SAS 'C' can make a 124 byte executable >(88 bytes of code). > 10% faster in clock cycles?? Have you counted the about 4.8 Zilion cycles requierd to put a character on the screen :-) >* >* Hello world in assembler language >* >* Programmed by Mike Schwartz in 1 minute. Optimized in 1 minute more. >* >* assembles into 112 byte executable (75 byte codesize) in .733 seconds. >* > >* The INCDIR directive tells the assembler where the include files are > INCDIR include: >* The OUTPUT directive tells the assembler the name of the output file > OUTPUT hello > > INCLUDE lvo/exec.lvo > INCLUDE lvo/dos.lvo > >EXECBASE equ 4 > >Main lea dosName(pc),a1 > moveq #0,d0 > move.w (EXECBASE).w,a6 > jsr _LVOOpenLibrary(a6) Whats wrong with OldOpenLibrary? It will do the same thing, but not require a parameter. > tst.l d0 > beq.s Exit > > move.l d0,a6 > jsr _LVOOutput(a6) > > move.l d0,d1 > move.l #hello,d2 This makes the code non-relocatable. Now the assembler must add an extra hunk to fix that. lea hello(pc),a0 followed by move.l a0,d2 also takes 4 bytes, but wont need this table. > moveq.l #helloLen,d3 > jsr _LVOWrite(a6) > > move.l a6,a1 > move.l (EXECBASE).w,a6 > jmp _LVOCloseLibrary(a6) > >Exit rts > >hello dc.b "Hello, world",10 >helloLen equ *-hello > >dosName dc.b 'dos.library',0 > > /$DR.HEX$