[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

To the HC11 Number Gurus



Hiya all,

First of all its been a while since I've said anything, and I know how
its late and all, but Happy New Year, well, Happy Holidays anyhow. 

I've been busy looking at some Delco coding and I've been rather stumped
about negative numbers with 16 bit registers. Firstly, I understand the
concept of ones and twos complement, so I get that the MSB decides
whether its negative or positive.... or whether you want to think of it
as change all the 1s to 0s and vice versa, then add one... so that's all
candy dandy.

ANYHOW, getting right back to my query, I was rather stumped on how the
HC11 differ positive numbers which are 8 bits, and negative numbers
which are also 8-bit? I do realise that there is a negative flag, or N
flag, and the Ref Manual just says that it is basically doing the same
thing as the MSB. It even goes on to say that the negative flag can be
used to monitor bit 7. Does this flag however only get used when the
number is negative? Is there some way to differentiate the difference
(hehe) between a positive or negative number in the HC11, or does it
rely on plain coding?

In other words, does the HC11 know that a number is negative and when
you add it to a positive number it does the add it up properly? 
e.g.
 		8000 + ( - A ) = 7FF6

or does it turn out to be:
		
		8000 + (+ F6 ) = 80F6
 
This question came about basically when I didn't understand how
something was supposed to be decreasing however an "ADD D" command was
being issued. I have already checked out the overflow, but that isn't
it... I guess that a negative number is the only possible way... but
then again. Any suggestions guys?
 
Cheers,
Andrew.
----------------------------------------------------------------------------
To unsubscribe from gmecm, send "unsubscribe gmecm" (without the quotes)
in the body of a message (not the subject) to majordomo@lists.diy-efi.org