home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / sys / amiga / programm / 12376 < prev    next >
Encoding:
Internet Message Format  |  1992-08-16  |  2.0 KB

  1. Path: sparky!uunet!usc!sol.ctr.columbia.edu!ira.uka.de!smurf.sub.org!easix!quax.GUN.de!peti.GUN.de!simons
  2. From: simons@peti.GUN.de (Peter Simons)
  3. Message-ID: <1409.ANN@peti.GUN.de>
  4. Date: Sat, 15 Aug 1992 16:42:34 CET
  5. Organization: * Private Amiga Site Bonn *
  6. Newsgroups: comp.sys.amiga.programmer
  7. Distribution: world
  8. Subject: Re: Is this legal assembly code?
  9. References: <1992Aug11.122845.15395@mits.mdata.fi>
  10. X-Newsreader: Ann 0.9
  11. Lines: 57
  12.  
  13. In article <1992Aug11.122845.15395@mits.mdata.fi>,
  14.         rkaivola@mits.mdata.fi (Risto Kaivola) writes:
  15.  
  16.  RK> I would like to know if the following assembly  language  program
  17.  RK> is legal or illegal:
  18.  RK>
  19.  RK>        IFEQ label1-label2
  20.  RK>        rts
  21.  RK>        ENDC
  22.  RK>
  23.  RK>        rts
  24.  RK> label1
  25.  RK>        move.l a0,a0
  26.  RK> label2 rts
  27.  RK>        END
  28.  RK>
  29.  RK> [...] I tried this on  A68k  (version  2.71,  I  think),  and  it
  30.  RK> complained of a duplicate  symbol.  Would  you  try  it  on  your
  31.  RK> assembler and tell me what it thinks of it, please? [...]
  32.  
  33.      This code is not really illegal, but  not  many  assemblers  will
  34.      assemble this correctly. The problem  is  the  forward-reference!
  35.      The value of the  labels  will  change  if  any  changes  to  the
  36.      code-size occur during the assembling-passes.
  37.  
  38. Example:
  39. GO              MACRO
  40.         IFGE (\1-*)-127
  41.                 bra.b   \1
  42.         ELSE
  43.                 bra     \1
  44.         ENDC
  45.                 ENDM
  46.                 .
  47.                 .
  48.                 .
  49.  
  50.                 GO      testlabel
  51.                 .
  52.                 .
  53.                 .
  54.                 move.l  #0,d0
  55. label           bsr     _foobar
  56.  
  57.      Most assemblers will evaluate the labels in pass 1  and  optimize
  58.      the "move.l" to "moveq" in pass  2,  which  will  make  the  code
  59.      shorter!!!
  60.  
  61.      The only assembler - I know - that supports forward-references is
  62.      Macro68k, but you have to disable *ALL* optimizations!
  63.  
  64.         bye, Peter
  65.  
  66.  
  67. --
  68.             Peter Simons           FIDO-Net          USE-Net
  69.        +49 (0)228-746061 Voice   2:2402/320.5   simons@peti.GUN.de
  70.