Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Larry Sendlosky <larry@scrugs.lkg.dec.com>
To: axp-list@redhat.com
Subject: Re: Weird Compaq CCC / GCC interaction ?
Date: Tue, 26 Sep 2000 13:25:47 EDT	[thread overview]
Message-ID: <CMM.0.90.4.969989147.larry@scrugs.lkg.dec.com> (raw)
In-Reply-To: Your message of Tue, 26 Sep 2000 10:02:27 -0600 (MDT)


I haven't seen any of this thread, but the quoted spec is correct and
makes sense. Given the example below

MAGIC is an unsigned int (32bits) with value 0xc00fc00f. The compiler
should generate 0x00000000c00fc00f for the register value. This is
"sign extending" an unsigned int (there is no sign bit or it's
"inferred" to be zero).

If MAGIC was defined as int 0xc00fc00f, then the register value
should be 0xffffffffc00fc00f. int 0xc00fc00f is a negative number.


larry


> > 
> > According to the Calling Standard for Alpha Systems, Section 4.1.5 "Unused
> > Bits in Passed Data," both signed and unsigned ints should be passed
> > sign-extended in registers.
> 
> Good to know but why this convention?  If I follow implications
> correctly (which is a big IF) then if I take results of such function
> returning unsigned int, like in the example, and will cast its result to
> long then I may get a negative number.  OTOH if I do:
> 
> #define MAGIC 0xc00fc00fU
> ...
>    printf ("%ld\n", (long)MAGIC);
> ...
> 
> then result is positive and I would be quite surprised otherwise.
> Or this Standard makes this also into a bug and expects that the
> cast above is equivalent to (long)((int)MAGIC)?  If yes then again
> why?
> 
>   Michal
> 
> 
> 
> _______________________________________________
> Axp-list mailing list
> Axp-list@redhat.com
> https://listman.redhat.com/mailman/listinfo/axp-list
> 



______________________________________________________________________
 Larry Sendlosky			 	            ATS
 larry@scrugs.lkg.dec.com (978) 506-6640                    Compaq
----------------------------------------------------------------------




             reply	other threads:[~2000-09-26 17:26 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-09-26 17:25 Larry Sendlosky [this message]
2000-09-26 18:01 ` Weird Compaq CCC / GCC interaction ? Michal Jaegermann
2000-09-27  3:17 ` Richard Henderson
  -- strict thread matches above, loose matches on Subject: below --
2000-09-26 18:52 Larry Sendlosky
2000-09-26 17:47 David Addison
2000-09-26 13:59 David Addison
2000-09-26 15:36 ` Ivan Kokshaysky
2000-09-26  8:55 David Addison
2000-09-26  9:41 ` Andrei A. Dergatchev
2000-09-26 10:12 ` Nikita Schmidt
2000-09-26 16:02   ` Michal Jaegermann
2000-09-26 12:23 ` Ivan Kokshaysky
2000-09-26 13:57 ` Ivan Kokshaysky
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox