#define CLEARV state->VFlag = 0
#define ASSIGNV(res) state->VFlag = res
+
#define IFLAG (state->IFFlags >> 1)
#define FFLAG (state->IFFlags & 1)
#define IFFLAGS state->IFFlags
extern void ARMul_MSRCpsr(ARMul_State *state, ARMword instr, ARMword rhs) ;
extern void ARMul_NegZero(ARMul_State *state, ARMword result) ;
extern void ARMul_AddCarry(ARMul_State *state, ARMword a, ARMword b, ARMword result) ;
+extern int AddOverflow(ARMword a, ARMword b, ARMword result) ;
+extern int SubOverflow(ARMword a, ARMword b, ARMword result) ;
extern void ARMul_AddOverflow(ARMul_State *state, ARMword a, ARMword b, ARMword result) ;
extern void ARMul_SubCarry(ARMul_State *state, ARMword a, ARMword b, ARMword result) ;
extern void ARMul_SubOverflow(ARMul_State *state, ARMword a, ARMword b, ARMword result) ;
else { CLEARN ; CLEARZ ; } ;
}
+/* Compute whether an addition of A and B, giving RESULT, overflowed. */
+int AddOverflow (ARMword a, ARMword b, ARMword result)
+{
+ return ((NEG (a) && NEG (b) && POS (result))
+ || (POS (a) && POS (b) && NEG (result)));
+}
+
+/* Compute whether a subtraction of A and B, giving RESULT, overflowed. */
+int SubOverflow (ARMword a, ARMword b, ARMword result)
+{
+ return ((NEG (a) && POS (b) && POS (result))
+ || (POS (a) && NEG (b) && NEG (result)));
+}
+
/***************************************************************************\
* Assigns the C flag after an addition of a and b to give result *
\***************************************************************************/
void ARMul_AddOverflow(ARMul_State *state, ARMword a,ARMword b,ARMword result)
{
- ASSIGNV( (NEG(a) && NEG(b) && POS(result)) ||
- (POS(a) && POS(b) && NEG(result)) ) ;
- }
+ ASSIGNV (AddOverflow (a, b, result));
+}
/***************************************************************************\
* Assigns the C flag after an subtraction of a and b to give result *
void ARMul_SubOverflow(ARMul_State *state,ARMword a,ARMword b,ARMword result)
{
-ASSIGNV( (NEG(a) && POS(b) && POS(result)) ||
- (POS(a) && NEG(b) && NEG(result)) ) ;
+ ASSIGNV (SubOverflow (a, b, result));
}
/***************************************************************************\