public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* M68K MRI Mode "Bug" with Local Labels?
@ 2021-10-31  7:09 Project Revolution
  2021-11-17 17:27 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: Project Revolution @ 2021-10-31  7:09 UTC (permalink / raw)
  To: binutils

Gentlemen,

I've been trying to figure out how to declare local labels similar to "@loop:" and the like, like what ASM68K supports, however, --mri mode didnt seem to support that syntax. However, while exploring alternatives, I ran into this peculiar test code:

MyGlobalLabel1:
1:
    dbf %d6,1b
    dbf %d6,MyGlobalLabel1

MyGlobalLabel2:
1:
    dbf %d6,1b
    dbf %d6,MyGlobalLabel2

If assembled with "m68k-linux-gnu-as test.asm -o test.o" it generates the expected offsets (hint: both dbf instructions need to reference the same label). However, if you add --mri, it no longer generates sensible offsets for those local label instructions, in fact it has pretty nonsense offsets (6 and E for some reason). What's going on here? Is there a function scope way to do local labels like what ASM68K supported out of the box? Is this a bug? We need --mri for what we are doing: removing this flag is not an option.

I have asked around including in the GCC IRC and they all basically referred me here; I am unsure if I am looking at assembler bug or not since the docs for M68K assembler are so sparce and thin.


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: M68K MRI Mode "Bug" with Local Labels?
  2021-10-31  7:09 M68K MRI Mode "Bug" with Local Labels? Project Revolution
@ 2021-11-17 17:27 ` Nick Clifton
  0 siblings, 0 replies; 2+ messages in thread
From: Nick Clifton @ 2021-11-17 17:27 UTC (permalink / raw)
  To: Project Revolution, binutils

Dear Project Revolution,

> MyGlobalLabel1:
> 1:
>      dbf %d6,1b
>      dbf %d6,MyGlobalLabel1
> 
> MyGlobalLabel2:
> 1:
>      dbf %d6,1b
>      dbf %d6,MyGlobalLabel2
> 
> If assembled with "m68k-linux-gnu-as test.asm -o test.o" it generates the expected offsets (hint: both dbf instructions need to reference the same label). However, if you add --mri, it no longer generates sensible offsets for those local label instructions, in fact it has pretty nonsense offsets (6 and E for some reason). What's going on here? 

Off the top of my head: "local labels do not work in MRI mode".
Which is not hugely surprising since they are kind of a gas-specific feature.


Is there a function scope way to do local labels like what ASM68K supported out of the box? Is this a bug? We need --mri for what we are doing: removing this flag is not an 
option.

How about using a macro ?  eg:

   fred MACRO
   MyGlobalLabel\@:
   .L\@:
       dbf %d6,.L\@
       dbf %d6,MyGlobalLabel\@
   ENDM

	fred
	fred

Which gives:

   % as fred.s -o fred.o.mri --mri
   % objdump -dr fred.o.mri
   00000000 <MyGlobalLabel0>:
    0:	51ce fffe      	dbf %d6,0 <MyGlobalLabel0>
    4:	51ce fffa      	dbf %d6,0 <MyGlobalLabel0>

   00000008 <MyGlobalLabel1>:
    8:	51ce fffe      	dbf %d6,8 <MyGlobalLabel1>
    c:	51ce fffa      	dbf %d6,8 <MyGlobalLabel1>

Cheers
   Nick


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2021-11-17 17:28 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-31  7:09 M68K MRI Mode "Bug" with Local Labels? Project Revolution
2021-11-17 17:27 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).