Say we have the addition of the following two registers:

R0 = 6DEE 8765 R1 = 3458 FFDD R0 + R1 = A2478742 

Assuming we are using a 2's complement sign convention, what flags would be set? I know that overthrow would be set, but would "N" as well?

Regards

5

1 Answer

In all architectures that support flags, the N or Negative flag simply matches the most significant bit of the last number computed.
In addition many architectures have a O or Overflow flag which tells you if the most significant bit was changed by the last operation.

If a register went from positive to negative both O and N will be set.
If the value in the register was negative before and after N will be set, but not O. etc.

The overflow flag is only useful when using signed arithmetic. When using unsigned arithmetic you use the C (Carry) flag, which tells you when the result exceeded the largest result the register can hold (0xFFFF FFFF in 32-bit).

Finally there is the Z zero flag which tells you if the result is zero or not.

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.