public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Richard Sandiford <rsandifo@redhat.com>
To: binutils@sources.redhat.com
Subject: Re: Bignums and .sleb128
Date: Mon, 31 Jan 2005 22:18:00 -0000	[thread overview]
Message-ID: <87sm4hqm3v.fsf@firetop.home> (raw)
In-Reply-To: <20050131215739.GA11513@nevyn.them.org> (Daniel Jacobowitz's message of "Mon, 31 Jan 2005 16:57:39 -0500")

Daniel Jacobowitz <drow@false.org> writes:
>> You said later that:
>> 
>> > If we're going to use these semantics, at least the '-' case in
>> > operand() needs to be fixed.
>> 
>> but I wasn't sure what you meant by "these semantics".  Do you mean
>> treating bignums as signed, or treating them as unsigned?  By my reading,
>> operand()'s current handling of '-' already assumes they are signed,
>> just like the sleb128 code does (and did ;).
>
> It doesn't work, because sometimes bignums are signed and sometimes
> they aren't.  Consider -0xffffffffffff; the current code will return 1. 
> If you want to treat the input as unsigned, then you need to add a new
> word with the sign bit.  Note that with one less leading 'f', it
> suddenly works.

Right, that's exactly the point I made later.  Like you say, if you
treat the bignum as signed (as the current '-' code does), then
{0xffff, 0xffff, 0xffff} is an invalid representation of a positive
number, it should be {0xffff, 0xffff, 0xffff, 0x0000} instead.
So the '-' code _does_ seem OK if you treat bignums as signed,
the problem is that the integer parsing code is still assuming
that bignums are unsigned, and that the extra 0x0000 littlenum
isn't needed.

I couldn't tell whether that's what you were saying too, or whether
you think that opcode() is wrong even if bignums are treated as signed.
It's quite possible we're in violent agreement here ;)

> One approach to fix the problem would be to define X_unsigned as a
> secondary "sign bit" for the bignum.  The core changes for that would
> be easy.  It's the backends that bother me.

I guess that's one way, but both existing bits of "bignums are signed"
code just use the top bit of the bignum as the sign bit.  Maybe that is
the most natural representation?

Richard

  reply	other threads:[~2005-01-31 22:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-01-31 19:54 Daniel Jacobowitz
2005-01-31 21:33 ` Richard Sandiford
2005-01-31 21:57   ` Daniel Jacobowitz
2005-01-31 22:18     ` Richard Sandiford [this message]
2005-01-31 22:22       ` Daniel Jacobowitz
2005-02-01  0:53 Paul Schlie
2005-02-01  1:09 ` Paul Schlie
2005-02-01  5:04   ` Paul Schlie
2005-02-01  3:29 ` Daniel Jacobowitz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87sm4hqm3v.fsf@firetop.home \
    --to=rsandifo@redhat.com \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).