MCPcopy Create free account
hub / github.com/PCSX2/pcsx2 / _add64_Overflow

Function _add64_Overflow

pcsx2/R5900OpcodeImpl.cpp:22–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

20bool gsIsInterlaced = false;
21
22static __fi bool _add64_Overflow( s64 x, s64 y, s64 &ret )
23{
24 const s64 result = x + y;
25
26 // Let's all give gigaherz a big round of applause for finding this gem,
27 // which apparently works, and generates compact/fast x86 code too (the
28 // other method below is like 5-10 times slower).
29
30 if( ((~(x^y))&(x^result)) < 0 ) {
31 cpuException(0x30, cpuRegs.branch); // fixme: is 0x30 right for overflow??
32 return true;
33 }
34
35 // the not-as-fast style!
36 //if( ((x >= 0) && (y >= 0) && (result < 0)) ||
37 // ((x < 0) && (y < 0) && (result >= 0)) )
38 // cpuException(0x30, cpuRegs.branch);
39
40 ret = result;
41 return false;
42}
43
44static __fi bool _add32_Overflow( s32 x, s32 y, s64 &ret )
45{

Callers 3

DADDIFunction · 0.85
DADDFunction · 0.85
DSUBFunction · 0.85

Calls 1

cpuExceptionFunction · 0.85

Tested by

no test coverage detected