Integer overflow: Difference between revisions

m
Line 156:
SUB.B #1,D0 ;WILL SET THE OVERFLOW FLAG SINCE AT BYTE LENGTH WE CROSSED FROM 80 TO 7F</lang>
 
Like the 6502, the 68000 doesn'twill carecontinue aboutwith overflowthe wrong result unless you tell it to stop. As with the majority of computer architectures, whether a value is "signed" or "unsigned" is not actually a property of the value itself, but of the comparators used to evaluate it. Otherwise even unsigned arithmetic would produce overflow errors! There are a few options for handling overflow errors:
* <code>TRAPV</code> will call an exception handler if the overflow flag is set, otherwise it will do nothing.
* <code>DBVS Dn</code> will loop a section of code until the overflow flag is set or the chosen data register is decremented to 0xFFFF, whichever occurs first.
1,489

edits