home | list info | list archive | date index | thread index

Re: [OCLUG-Tech] Double checking re: twos complement & signed types ??

  • Subject: Re: [OCLUG-Tech] Double checking re: twos complement & signed types ??
  • From: William Case <billlinux [ at ] rogers [ dot ] com>
  • Date: Fri, 21 Sep 2007 00:57:56 -0400
Thank you Brenda;

I appreciate the time and care you have taken with this response.  I
will go through it very carefully in the morning.  Perhaps I am feeling
a bit defencive because this dialogue has gone on so long.  I am taking
the opportunity to respond to just one part of your post this evening.

On Thu, 2007-09-20 at 18:14 -0400, Brenda J. Butler wrote:
> Bill,
> 
> On Wed, Sep 19, 2007 at 01:20:35PM -0400, William Case wrote:
> 
> Basically, you missed out this part of what I (and Bart) said:
> 
> > > A signed integer and an unsigned integer are not treated differently
> > > by the machine.  When they get added together, or subtracted
> > > or whatever, they have exactly the same effect upon the accumulator
> > > and the status register (NCZV).
> 
> Signed integers and unsigned integers are treated the same by the
> ALU.  The ALU does not care if a given number in the accumulator
> is "signed" or "unsigned".  It will treat it the same way.
> 
> CPU's don't care about signed vs unsigned.  Compilers make that
> distinction.
> 
In fact, this part came through loud and clear.  It was why I shifted my
question to the role of the compiler, optimization and the final value
that might be created by the compiler taking negative numbers and
subtraction operators in the source into account.  Since the ALU didn't
care whether a number was signed or unsigned, it seemed safe to assume
any changes that had to be made were made prior to a final value being
placed in RAM and eventually arriving at an ALU register.


> > > It is what the C compiler does with the contents of the accumulator and
> > > the status register that makes it signed or unsigned.
> > > 

After the compilers has run and converted the source into binary, how
can it have any impact on what is in the accumulator and the status
register.  Unless I have really missed something, the values that will
eventually end up here have to be previously compiled.  Even if a
variable value is the result of some earlier calculation, the
instruction code (op code) for the program has to contain instruction on
altering that data so that it can be used?  At least, that was how I
read and considered your remarks.  In any case, let me read through your
latest in the morning.

> > 
> > I gather you are saying, that if there is a subtraction operation in
> > some C code, it is the *compiler* that alters the value of the number to
> > be subtracted (or negated) into it's two's complement binary

Perhaps I am being overly sensitive, but I wouldn't want you, or Bart or
any of the others who have spent so much time helping me, to think that
I don't take your replies seriously and that I don't read them in full.

Also, I respect your opinion and I don't want you to think I am just
straight stupid.

-- 
Regards Bill