Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
09/08/05 12:45
Read: times


 
#100802 - Explanation
Responding to: ???'s previous message
I'll try to give an explanation on what, and why, it is considered to be a negative value of a binary number.

Let's take a usual binary counter, for example with 8 stages (8 bits). Every pulse increments its state, so that it shows ...000, ...001, ...010, etc. Every time a stage changes from 1 to 0, it also makes the pulse for the next higher stage. We know that an 8 bit counter has 256 different states.
What happens when all 8 stages are 1 and a new pulse comes ? The lowest will go to 0, so the next receives pulse and goes to 0 and so on. The highest also goes to 0, but its pulse doesn't affect any stage, because there is no higher. So, after 1...11, we are back to all zeroes. In that way, the counter counts cyclically in a closed loop.

Counting down would make a similar effect, after 0, all stages come to all 1's and so on. Addition or subtraction of some values makes the same effect as counting up or down.

(Exactly the same is behaviour of a mechanical counter, which you can turn up or down!)

So, the value of FFh may be considered as -1, because we get 0 when 1 is added. FEh is then -2, and so on. So called Signed integers take the lower half of the range (MSB is 0) as positive and upper half (MSB is 1) as negative. To get a negative number of ACC, you should perform:
     CPL   A
     INC   A.
(If you like to play, apply this formula to the values: 1, 2, FDh, 0, 128 !)

As timer counters all count up, when we decide about reloading value for a timer, we express it as a negative value, because that's exactly the number of counts before the counter reaches the top-to-zero transition.


Slobodan

List of 32 messages in thread
TopicAuthorDate
why -ve sign is used in cal of baudrate            01/01/70 00:00      
   The timer counts UP            01/01/70 00:00      
   I have seen much Stupid Monkey Shit, but            01/01/70 00:00      
      Well established            01/01/70 00:00      
         4 i=1 2 3            01/01/70 00:00      
            Not taught            01/01/70 00:00      
               XTAL...            01/01/70 00:00      
                  -ve, +ve, xtal            01/01/70 00:00      
                     If all involved totally and without any            01/01/70 00:00      
                        Abbreviations            01/01/70 00:00      
                           a bit tedious, I would say that every no            01/01/70 00:00      
                              Yes, but            01/01/70 00:00      
                                 ASCII            01/01/70 00:00      
                              abreviations            01/01/70 00:00      
                                 Let me try to fly this baloon:            01/01/70 00:00      
                                    lol            01/01/70 00:00      
                                 What can be abbreviated?            01/01/70 00:00      
                                    addendum            01/01/70 00:00      
                                 Not another glossary!!            01/01/70 00:00      
                                    [OT]: DDCMP            01/01/70 00:00      
                                       [OT] Re: DDCMP            01/01/70 00:00      
                                    no glossary            01/01/70 00:00      
                     history            01/01/70 00:00      
   Need logical answer            01/01/70 00:00      
      Did not understand            01/01/70 00:00      
         HI            01/01/70 00:00      
      nobody is "making fun" just stressing th            01/01/70 00:00      
      Explanation            01/01/70 00:00      
      You are calling the kettle black            01/01/70 00:00      
   Need logical answer            01/01/70 00:00      
      Logical Answer            01/01/70 00:00      
   Thanks and Regards            01/01/70 00:00      

Back to Subject List