9fans - fans of the OS Plan 9 from Bell Labs
 help / color / mirror / Atom feed
From: maht <maht-9fans@maht0x0r.net>
To: Fans of the OS Plan 9 from Bell Labs <9fans@9fans.net>
Subject: Re: [9fans] portability question
Date: Wed, 16 Jun 2010 14:30:00 +0100	[thread overview]
Message-ID: <4C18D1D8.2060301@maht0x0r.net> (raw)
In-Reply-To: <AANLkTinYjxYQEDBK5u2kohjRwdZA-wIB9hK8nVVnITuV@mail.gmail.com>

On 06/16/10 10:11, hugo rivera wrote:
> Can someone clarify why the program included outputs 'AB000000' (as I
> expect) on 32 bit systems and 'FFFFFFFFAB000000' on 64 bit systems?
> where all those 1's came from? what's the portable way of doing this?
> sorry for newbie questions like this.
>
>
>        unsigned long l;
>         unsigned char c;
>
>         l = 0L;
>         c = 0xAB;
>         l |= c << 24;
>         printf("%lX\n", l);
>
>

check the ASM, looks like c is being cast as signed and then sign
extended into a long and then ORed with l.

perhaps this would solve it :

l |= ((unsigned long) c) << 24


But I can't check



  parent reply	other threads:[~2010-06-16 13:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-16  9:11 hugo rivera
2010-06-16 10:01 ` Lucio De Re
2010-06-16 10:15   ` hugo rivera
2010-06-16 10:27   ` Charles Forsyth
2010-06-16 13:30 ` maht [this message]
2010-06-16 15:26   ` erik quanstrom
2010-06-16 17:52 ` Bakul Shah
2010-06-17  7:50   ` hugo rivera

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=4C18D1D8.2060301@maht0x0r.net \
    --to=maht-9fans@maht0x0r.net \
    --cc=9fans@9fans.net \
    /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 NNTP newsgroup(s).