Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision | |||
|
psx:cpu:division [2012/10/23 13:12] amidog |
psx:cpu:division [2012/10/23 13:17] (current) amidog |
||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | The PSX has a few undefined cases when it comes to division. It's important to remeber than undefined isn't the same as inconsistent or unstable, and as a result, there are games out the which relies on this undefined behavior. | + | The PSX has a few undefined cases when it comes to division. It's important to remeber that undefined isn't the same as inconsistent or unstable, and as a result, there are games out there which relies on this undefined behavior. |
| ====== Signed division by zero ====== | ====== Signed division by zero ====== | ||
| - | The result of a division by zero is consistent with the result of a smiple radix-2 ("one bit at a time") implementation. That is, if the dividend is negative, the quotient is 1 (0x00000001), and if the dividend is positive or zero, the quotient is -1 (0xffffffff). In both cases the remainder equals the dividend. | + | The result of a division by zero is consistent with the result of a simple radix-2 ("one bit at a time") implementation. That is, if the dividend is negative, the quotient is 1 (0x00000001), and if the dividend is positive or zero, the quotient is -1 (0xffffffff). In both cases the remainder equals the dividend. |
| ====== Unsigned division by zero ====== | ====== Unsigned division by zero ====== | ||
| Line 8: | Line 8: | ||
| ====== Signed division of most negative by minus one ====== | ====== Signed division of most negative by minus one ====== | ||
| - | This is actually quite interesting, not the result of the operation, but the fact that some CPUs (x86 for example) will trigger an arithmetic exception when dividing 0x80000000 by 0xffffffff. Thus you may be able to crash your favourite (x86) PSX emulator by a few lines of MIPS code. The result of the operation is a quotient of 0x80000000 and a remainder of 0x00000000. | + | This is actually quite interesting, not the result of the operation, but the fact that some CPUs (x86 for example) will trigger an arithmetic exception when dividing 0x80000000 by 0xffffffff. Thus, unless your favourite (x86) emulator handles this case, you may be able to crash it with a few lines of MIPS code. The result of the division is a quotient of 0x80000000 and a remainder of 0x00000000. |