🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.utils.bug
Article #190

Branch addressing bug in GAS-1.92.3 / 68k

#190
From: Andrew Smith
Date: Mon, 03 Aug 1992 17:19
60 lines
2127 bytes
 Steve(s),

> In article <9207301722.AA00678@zaphod.synoptics.com> you write:
> [ ... ]
> >I have a GAS called gas-1.92.3 which supports all of the 68040 MMU opcodes
> >but not the 68030 ones. Any ideas?
> 
> Can't help you with the 68030 MMU stuff, but I can offer a word of
> caution:  Don't trust gas-1.92.3.  I've noticed that in some (all?)
> cases, it miscomputes offsets for relative branches.
> 
> But don't take my word for it, try the following test case:
> 
> >  	.globl  test
> >  	.text
> >  test:
> >  	bnes	label
> >  	bne 	label
> >  	bnel	label
> >  	nop
> >  label:	rts
> 
> The output of 'objdump -d' on my Sparc reads:
> 
> > test.o:     file format a.out-sunos-big
> [ ... ]
> > 00000000 (label-)000e bnes 0000000f (label+)0001
> > 00000002 (test+)0002 bne 00000010 (label+)0002
> > 00000006 (test+)0006 bnel 00000012 (label+)0004
> > 0000000c (test+)000c nop
> > 0000000e (test+)000e rts
> [ ... ]
> 

I tried your example and you're right - so I wondered how any of my code could ever
run at all! Then I thought about what it says in the manual about "Optimised 
Branch" instructions. If you write 

test:
  	jne	label
  	jne 	label
  	jne	label  
	nop

  label:	rts

You get the correct answers! Strange .....

I don't know how it can be wrong on "bne" but get a pseudo-op "jne" correct: looks
like someone broke the simple case in order to get the optimisation working. 

I am copying this to the list and to sac@cygnus.com (I don't know if Steve 
Chamberlain at Cygnus looks after the 68k assembler as well as other ones but he'll 
know who to get to fix it!).



Andrew Smith
Distributed Network Systems
SynOptics Communications Inc.
Technical Details
Message-ID: <9208031719.AA08940@zaphod.synoptics.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!synoptics.com!asmith

Show Full Headers
Complete Article Headers
Newsgroups: gnu.utils.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!synoptics.com!asmith
From: asmith@synoptics.com (Andrew Smith)
Subject: Branch addressing bug in GAS-1.92.3 / 68k
Message-ID: <9208031719.AA08940@zaphod.synoptics.com>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Mon, 3 Aug 1992 17:19:18 GMT
Approved: bug-gnu-utils@prep.ai.mit.edu
Lines: 62