Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!snorkelwacker.mit.edu!bloom-beacon!eru!hagbard!sunic!cs.umu.se!dvljrt From: dvljrt@cs.umu.se (Joakim Rosqvist) Newsgroups: comp.sys.amiga.advocacy Subject: Re: Short Hello World Message-ID: <1991May5.094238.26014@cs.umu.se> Date: 5 May 91 09:42:38 GMT References: <1991Apr30.213936.22878@ux1.cso.uiuc.edu> <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: 40 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. What!?! In my opinion I use only 1 "magic" number, The address 4, which is blessed by Commodore. The 3 values you are talking about are index:es in a jump-table, which remain the same with new releases. That's what jump-tables are for, otherwise you could jump directly to a ROM-address (which even I wouldn't do) /$DR.HEX$