/* DIV */
case 6:
{
- UCHAR Quotient = State->GeneralRegs[FAST486_REG_EAX].LowWord / Value;
- UCHAR Remainder = State->GeneralRegs[FAST486_REG_EAX].LowWord % Value;
+ UCHAR Quotient, Remainder;
+
+ if (Value == 0)
+ {
+ /* Divide error */
+ Fast486Exception(State, FAST486_EXCEPTION_DE);
+ return FALSE;
+ }
+
+ Quotient = State->GeneralRegs[FAST486_REG_EAX].LowWord / Value;
+ Remainder = State->GeneralRegs[FAST486_REG_EAX].LowWord % Value;
/* Write back the results */
State->GeneralRegs[FAST486_REG_EAX].LowByte = Quotient;
/* IDIV */
case 7:
{
- CHAR Quotient = (SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord / (CHAR)Value;
- CHAR Remainder = (SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord % (CHAR)Value;
+ CHAR Quotient, Remainder;
+
+ if (Value == 0)
+ {
+ /* Divide error */
+ Fast486Exception(State, FAST486_EXCEPTION_DE);
+ return FALSE;
+ }
+
+ Quotient = (SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord / (CHAR)Value;
+ Remainder = (SHORT)State->GeneralRegs[FAST486_REG_EAX].LowWord % (CHAR)Value;
/* Write back the results */
State->GeneralRegs[FAST486_REG_EAX].LowByte = (UCHAR)Quotient;
/* DIV */
case 6:
{
+ if (Value == 0)
+ {
+ /* Divide error */
+ Fast486Exception(State, FAST486_EXCEPTION_DE);
+ return FALSE;
+ }
+
if (OperandSize)
{
ULONGLONG Dividend = (ULONGLONG)State->GeneralRegs[FAST486_REG_EAX].Long
/* IDIV */
case 7:
{
+ if (Value == 0)
+ {
+ /* Divide error */
+ Fast486Exception(State, FAST486_EXCEPTION_DE);
+ return FALSE;
+ }
+
if (OperandSize)
{
LONGLONG Dividend = (LONGLONG)State->GeneralRegs[FAST486_REG_EAX].Long