Search code examples
assembly68000

Determining if unsigned overflow occurs on 68000


I am working on a question for school and can't understand this part that has to do with adding two numbers and checking if unsigned overflow occurs.

In the reference I am using, it says that both of the conditional tests VC (overflow clear) and VS (overflow set) are twos complement arithmetic and use signed numbers.

From what I understand, any of the conditional tests that use signed numbers won't work with unsigned numbers. Is there a different way I should be testing for this?


Solution

  • The OV flag is only valid for numbers you want to interpret as signed integers. It is set when any calculation passes the limit of +/- MAXINT (depending on operand size). You should ignore it normally when working with unsigned numbers. On a very low level, the OV flag is set when you add two numbers of the same sign and the result has its uppermost bit changed by a calculation.

    The C flag is relevant for both signed and unsigned numbers - It is set when any calculation passes the value zero.

    The conditional branches of the 68k CPU are sorted in conditions valid for signed and unsigned integers, watching combinations of V and C (and Z) flags, translating them into conditions >, =, >=, <, <=. For beginners, it is sometimes a bit confusing that identical instructions with idential opcodes may have more than one name: one that expresses the flag state, and another one that expresses "what the flags mean", like BCC (branch if carry clear) and BHS (branch if higher or same). Both of these evaluate to the same opcode.