From: "Martin Ward" <mar...@gkc.org.uk>
Sent: Saturday, April 30, 2022 7:27 PM


On Apr 29, 2022, at 12:08:22, Bob Raicer wrote:
The two's complement of the maximum negative number cannot be
represented in the same number of bits. ...

I think you mean "the absolute value (or the positive value)
of the maximum negative number cannot be represented in
the same number of bits." The two's complement of
the maximum negative number is just the maximum negative number:
which can, of course, be represented.

Um, the two's complement is not the correct representation of
the complement.  RTM, which says that overflow occurs.

On 2022-04-30 05:10, Paul Gilmartin wrote:
Surely it is possible
to invert all the bits of the maximum negative number, add a value
of one in the rightmost bit position, and *ignore*any*carry* out
of the sign position; the definition of "two's complement" above.
That's exactly what the LCR instruction does.

No it doesn't.  RTM.  The value in the register is unchanged
in this case.

If you do the calculation you will find that inverting all the bits
and adding one will leave the value in the register unchanged
when the value is the maximum negative number.

I have been complementing values for several decades.

But you need to RTM.  It says different.

"LNR
"The two's complement of the absolute value of the second operand
"is placed in the first operand location.
"The operation complements positive numbers;
"negative numbers REMAIN UNCHANGED.  The
"number zero REMAINS UNCHANGED with positive sign." (emphasis added)

"LCR
"An overflow condition occurs when the maximum negative
"number is complemented; the number REMAINS UNCHANGED." (emphasis added)

---
This email has been checked for viruses by Avast antivirus software.
https://www.avast.com/antivirus

Reply via email to