Path: utzoo!utgpu!cs.utexas.edu!sdd.hp.com!mips!pacbell.com!tandem!zorch!amiga0!mykes From: mykes@amiga0.SF-Bay.ORG (Mike Schwartz) Newsgroups: alt.sources.amiga Subject: Re: Short Hello World Message-ID: Date: 5 May 91 06:53:42 GMT References: <1991Apr30.213936.22878@ux1.cso.uiuc.edu> <1991May2.102554.8679@cs.umu.se> <1991May5.011748.11595@zorch.SF-Bay.ORG> Organization: Amiga makes it possible Lines: 103 In article <1991May5.011748.11595@zorch.SF-Bay.ORG> xanthian@zorch.SF-Bay.ORG (Kent Paul Dolan) writes: >dvljrt@cs.umu.se (Joakim Rosqvist) writes: > >> [some boring C-code deleted] :-) > >> Ok, assembler strikes back with this: (56 codesize, 92 executable) > >> OpenLib=-408 >> Output=-60 >> Write=-48 > >> move.l 4.w,a6 >> lea dos(pc),a1 >> jsr OpenLib(a6) >> move.l d0,a6 >> jsr Output(a6) >> move.l d0,d1 >> lea hello(pc),a0 >> move.l a0,d2 >> moveq #12,d3 >> jmp write(a6) > >> dos: dc 'dos.library',0 >> hello: dc 'Hello World',10 > >> /$DR.HEX$ > >And a better example of how _not_ to program would be hard to find. > >You've managed, in a 15 line program, to include 3 "magic numbers" >that are dependent on the release of dos.library, so that your code >need not merely be reassembled for an operating system upgrade, but >rewritten. Sprinkle an equivalent 20% fraction of bogosities into >100,000 lines of code, and you might as well throw it away and start >fresh as try to port it to the next release. > >Doing the linker's job for it is _not_ a smart move, as the first >three lines clearly demonstrate. > >If you are going to evade higher level languages to worship at the altar >of code size and speed, you have to work _much_ harder than this to >equal the high level language's relatively automatic maintainability >advantage. > >Kent, the man from xanth. > > 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). * * 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) tst.l d0 beq.s Exit move.l d0,a6 jsr _LVOOutput(a6) move.l d0,d1 move.l #hello,d2 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 -- **************************************************** * I want games that look like Shadow of the Beast * * but play like Leisure Suit Larry. * ****************************************************