public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* gas: inconsistencies w/ immediates
@ 2000-07-31  5:08 Andrew Morton
  2000-07-31  6:12 ` Andreas Schwab
  2000-07-31 21:31 ` Andrew Morton
  0 siblings, 2 replies; 4+ messages in thread
From: Andrew Morton @ 2000-07-31  5:08 UTC (permalink / raw)
  To: binutils

Using HJ's 2.9.5.0.34 binutils release (x86):

The handling of immediate constants appears to be inconsistent:


	movl	$1234,%eax

OK, this moves an immediate into eax.


	movl	$1234/$10,%eax

This fails because it is treating $10 as a label, not as a constant.


	.equ	some_label,$1234

Here, the assembler treats $1234 as a label!



This bizarre handling of $NNN really bites because this is the format in
which compiler-generated constants come out of GCC. For example, suppose
you wish to do this:


foo()
{
        asm(".equ SIZEOF_FOO,%0" :: "i" (sizeof foo));
}

bar()
{
        asm("movl $SIZEOF_FOO,%eax");
}

main()
{}

mnm:/home/morton> gcc -O x.c
/tmp/cc86xNLu1.o: In function `bar':
/tmp/cc86xNLu1.o(.text+0xc): undefined reference to `$1'


I'm unaware of any workaround which will allow the above to be done.


So is it possible to make the following changes:

1: Support $NN in gas expressions (I don't need this, but it
   seems sensible) and

2: Support $NN as integers (not labels) in pseudo-ops.

Thanks.

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

* Re: gas: inconsistencies w/ immediates
  2000-07-31  5:08 gas: inconsistencies w/ immediates Andrew Morton
@ 2000-07-31  6:12 ` Andreas Schwab
  2000-07-31  8:47   ` Alan Modra
  2000-07-31 21:31 ` Andrew Morton
  1 sibling, 1 reply; 4+ messages in thread
From: Andreas Schwab @ 2000-07-31  6:12 UTC (permalink / raw)
  To: Andrew Morton; +Cc: binutils

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1000 bytes --]

Andrew Morton <andrewm@uow.edu.au> writes:

|> Using HJ's 2.9.5.0.34 binutils release (x86):
|> 
|> The handling of immediate constants appears to be inconsistent:
|> 
|> 
|> 	movl	$1234,%eax
|> 
|> OK, this moves an immediate into eax.
|> 
|> 
|> 	movl	$1234/$10,%eax
|> 
|> This fails because it is treating $10 as a label, not as a constant.

Isn't `$' part of the insn syntax (immediate prefix)?  IMHO this should be
written as:

        movl    $1234/10,%eax

|> This bizarre handling of $NNN really bites because this is the format in
|> which compiler-generated constants come out of GCC. For example, suppose
|> you wish to do this:
|> 
|> 
|> foo()
|> {
|>         asm(".equ SIZEOF_FOO,%0" :: "i" (sizeof foo));
                                ^^
Try %c0.

Andreas.

-- 
Andreas Schwab                                  "And now for something
SuSE Labs                                        completely different."
Andreas.Schwab@suse.de
SuSE GmbH, Schanzäckerstr. 10, D-90443 Nürnberg

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

* Re: gas: inconsistencies w/ immediates
  2000-07-31  6:12 ` Andreas Schwab
@ 2000-07-31  8:47   ` Alan Modra
  0 siblings, 0 replies; 4+ messages in thread
From: Alan Modra @ 2000-07-31  8:47 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: Andrew Morton, binutils

On Mon, 31 Jul 2000, Andreas Schwab wrote:

> Andrew Morton <andrewm@uow.edu.au> writes:
> 
> |> 	movl	$1234/$10,%eax
> |> 
> |> This fails because it is treating $10 as a label, not as a constant.
> 
> Isn't `$' part of the insn syntax (immediate prefix)?

Yes.  Strictly speaking, it's part of the operand.

> IMHO this should be written as:
> 
>         movl    $1234/10,%eax

Correct again.  Watch out for versions of x86 gas that define `/' to start
the beginning of a comment, with disastrous results for division
expressions.

-- 
Linuxcare.  Support for the Revolution.

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

* Re: gas: inconsistencies w/ immediates
  2000-07-31  5:08 gas: inconsistencies w/ immediates Andrew Morton
  2000-07-31  6:12 ` Andreas Schwab
@ 2000-07-31 21:31 ` Andrew Morton
  1 sibling, 0 replies; 4+ messages in thread
From: Andrew Morton @ 2000-07-31 21:31 UTC (permalink / raw)
  To: binutils

Andreas wrote:
> 
|> foo()
|> {
|>         asm(".equ SIZEOF_FOO,%0" :: "i" (sizeof foo));
                                ^^
Try %c0.

Perfect.  Many thanks.

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

end of thread, other threads:[~2000-07-31 21:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-07-31  5:08 gas: inconsistencies w/ immediates Andrew Morton
2000-07-31  6:12 ` Andreas Schwab
2000-07-31  8:47   ` Alan Modra
2000-07-31 21:31 ` Andrew Morton

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).