Searching \ for ' 2-Compliment Addition/Subtraction. Ques' in subject line. ()
Help us get a faster server
Search entire site for: '2-Compliment Addition/Subtraction. Ques'.

No exact or substring matches. trying for part
2001\04\02@215726 by

Hello,

I finally dug out my digital systems book from way back in colledge, to
find out more about how two's compliment addition is used in the PIC
micro controller.  Now I have a few questions requarding how they are
contiguous for 16/24/ and 32 bit addition.

If the magitude of the addition is only 7 bits and the sign is the eight
bit, then how can the registers add a full 256 value on the lower byte
with no reguards to it's sign.  For instance, I the number 200 decimal
was added to 100 decimal.  The 2's complement of each of these would be:

200 = 0xC8 B'11001000'
-----------------------------------
2'CO = B'00110111'
+1
-----------------------------------
B'0111000'  (2's Compliment for.)  Sign bit is 0 meaning
positive number

100= 0x64 B'01100100'
-----------------------------------
2'sCo = B'10011011'
+1
-----------------------------------
B'10011100' (2'S Compliment) Sign bit is now 1 meaning negative,
this can't be?

Now we add the two as:
B'0111000'
+B'10011100'
------------------------------------
11010100        Then we compliment then again.
0010100 Carry bit is set.  Sign bit is zero.
But none of these are correct result value.

So my next question is:  Is the 7th Bit include in the 2's compliment
and addition?  Or is it just the first 7bits 0-6?
Next, is the carry by set because of bit position 6 addition or the
signed bit?

It has been many years since I have working with this kind of thing, so
please bare with me.  I must have a full understanding of what is
happening in order for me to program my Bresenham routine correctly.  I
have always programmed in C/C++ so this has not been an issue before.

Regards,

James

--

>So my next question is:  Is the 7th Bit include in the 2's compliment
>and addition?  Or is it just the first 7bits 0-6?
>Next, is the carry by set because of bit position 6 addition or the
>signed bit?

I think one of the problems you are having in getting to grips with 2 complement
is the concept of a sign bit. There is no single sign bit as such.

What makes the number positive or negative is its relation to 0. If the number
is "higher" than half the value that can be held in the memory location, then it
is considered negative, that is it is 0 - number. This why a 16 bit location can
hold +32767 to -32768 (Note the difference of 1 in the maximum values).

In an 8 bit location +1 = 00000001, and -1 = 11111111
+2 = 00000010, and -2 = 11111110

--
http://www.piclist.com hint: The list server can filter out subtopics
(like ads or off topics) for you. See http://www.piclist.com/#topics

More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...