Re: arm9e: how do I invert sign of a halfword?
- From: John Devereux <jdREMOVE@xxxxxxxxxxxxxxxxxx>
- Date: Thu, 31 Jul 2008 21:50:35 +0100
"Wilco Dijkstra" <Wilco.removethisDijkstra@xxxxxxxxxxxx> writes:
"CBFalconer" <cbfalconer@xxxxxxxxx> wrote in message news:4891B6EC.E7745854@xxxxxxxxxxxx
Wilco Dijkstra wrote:
"CBFalconer" <cbfalconer@xxxxxxxxx> wrote:
Wilco Dijkstra wrote:
"CBFalconer" <cbfalconer@xxxxxxxxx> wrote:... snip ...
Just consider the meaning and action on machines using ones
complement or sign-magnitude conventions. Also the fact that the
occurence of an overflow can cause implementation defined action.
I did consider that and this is exactly why the C standard is
incorrect:
Arithmetic one-complement shifts shift the sign into either the
MSB (right shift) or LSB (left shift). Sign magnitude only shifts
the magnitude for both left and right shift. This gives the
correct arithmetic results, ie. -0 stays -0, -1 becomes -0 on a
right shift, and -2 on a left shift etc.
Please give a reference section (s) in the C99 standard that
imposes this.
The standard has nothing to do with this. Remember you asked me to
"consider the meaning and action on machines using ones complement
or sign-magnitude conversions". That's what I did, and I described
how shifts work on such machines, and that there is clearly no
reason for left shifts to be undefined when right shifts are
implementation defined.
Once you understand that, you'll understand the C standard is
incorrect.
If you go back to the original post in this thread, you will find C
code proposed. In addition, something like 90% of embedded
programming is done in C. If you want to consider other languages,
it is necessary to state that in an obvious place.
Nobody is talking about other languages - we're talking about C
and how C translates onto machine instructions. If the underlying
machine instructions work correctly in different number representations
then the C operators that map onto them work correctly too.
The C standard allows for the use of non-standard systems and
extensions. However, any sane programmer makes sure such items are
clearly marked and identified. Your statement about the standard
is wrong, to put it gently.
You still haven't answered my question as to why left shifts are undefined
while right shifts are implementation defined. If you believe the standard
is correct, then explain why. "Because the standard says so" is not good
enough, especially since most software disagrees.
It's like how God exists because the bible tells me so. And since the
bible is the word of God, so it must be true.
--
John Devereux
.
- References:
- Re: arm9e: how do I invert sign of a halfword?
- From: Everett M. Greene
- Re: arm9e: how do I invert sign of a halfword?
- From: CBFalconer
- Re: arm9e: how do I invert sign of a halfword?
- From: Wilco Dijkstra
- Re: arm9e: how do I invert sign of a halfword?
- From: CBFalconer
- Re: arm9e: how do I invert sign of a halfword?
- From: Wilco Dijkstra
- Re: arm9e: how do I invert sign of a halfword?
- From: CBFalconer
- Re: arm9e: how do I invert sign of a halfword?
- From: Wilco Dijkstra
- Re: arm9e: how do I invert sign of a halfword?
- From: CBFalconer
- Re: arm9e: how do I invert sign of a halfword?
- From: Wilco Dijkstra
- Re: arm9e: how do I invert sign of a halfword?
- From: CBFalconer
- Re: arm9e: how do I invert sign of a halfword?
- From: Wilco Dijkstra
- Re: arm9e: how do I invert sign of a halfword?
- Prev by Date: Re: Variable reluctance motor drive?
- Previous by thread: Re: arm9e: how do I invert sign of a halfword?
- Next by thread: Re: arm9e: how do I invert sign of a halfword?
- Index(es):
Relevant Pages
|