P1 PASM signed versus unsigned question
Hello forums.
Learning P1 PASM. Starting to get the hang of it. Ran into something that is confusing to me. Signed versus Unsigned.
First is my understanding of signed versus unsigned correct (see below summary) for a long PASM?
Signed
HEX DEC BIN
$FF_FF_FF_FF ---> -1 --> % 1111_1111_1111_1111_1111_1111_1111_1111
…
$80_00_00_01 ---> -2,147,483,647 --> % 1000_0000_0000_0000_0000_0000_0000_0001
$80_00_00_00 ---> 2,147,483,648 --> % 1000_0000_0000_0000_0000_0000_0000_0000
…
$00_00_00_00 ---> -1 --> % 0000_0000_0000_0000_0000_0000_0000_0000
Unsigned
$FF_FF_FF_FF ---> 4,294,967,295 --> % 1111_1111_1111_1111_1111_1111_1111_1111
…
$00_00_00_00 ---> 0 --> % 0000_0000_0000_0000_0000_0000_0000_0000
Second, I get confused, if I was keeping track of decimal values throughout my PASM code, I would not want to mix match signed and unsigned? For example, ADDABS is an instruction. If my destination was a signed value, does this change it to an unsigned value?
So I should be cautious and know that this happens based on the instruction being used? And not mix up signed and unsigned values? Thanks
Comments
ADDABS does not convert any representation of destination value.
( And maybe other addition/subtraction instructions do not, too. )
That representation of negative number is 2's complement, or 1's complement ( bitwise NOT ) plus one.
This implies that you can do addition or subtraction with any combination of unsigned, signed positive, or signed negative numbers consistently, with cares of some situations, for example, overflows, underflows, carries, borrows, etc..
If no overflow occurs, destination value can be as either signed or unsigned.
If overflow may occur, you need special cares for interpretation of results of operation.
ok thanks for your explanation. So the way the ADDABS instruction is implemented is so the C Result bit is "unsigned" and not "signed". And that may be why there is a difference between Carry Overflow (signed) versus Unsigned Carry (unsigned).