diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2010-10-29 02:20:47 -0700 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2010-10-29 02:20:47 -0700 |
commit | 373154a25afb1bed946e5a2a7cfd411e4bd7fad6 (patch) | |
tree | 6846c48532c04192f22645030ad2dc7c09ceae89 /src/arch/x86/isa | |
parent | 7378424b149a16cbc22a5b0260372beb8c8a0ac7 (diff) | |
download | gem5-373154a25afb1bed946e5a2a7cfd411e4bd7fad6.tar.xz |
X86: Fault on divide by zero instead of panicing.
Diffstat (limited to 'src/arch/x86/isa')
-rw-r--r-- | src/arch/x86/isa/microops/regop.isa | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/arch/x86/isa/microops/regop.isa b/src/arch/x86/isa/microops/regop.isa index 4b0080d40..9ccea82dd 100644 --- a/src/arch/x86/isa/microops/regop.isa +++ b/src/arch/x86/isa/microops/regop.isa @@ -178,8 +178,7 @@ output decoder {{ uint64_t "ient, uint64_t &remainder) { //Check for divide by zero. - if (divisor == 0) - panic("Divide by zero!\\n"); + assert(divisor != 0); //If the divisor is bigger than the dividend, don't do anything. if (divisor <= dividend) { //Shift the divisor so it's msb lines up with the dividend. @@ -518,11 +517,15 @@ let {{ //This is a temporary just for consistency and clarity. uint64_t dividend = remainder; //Do the division. - divide(dividend, divisor, quotient, remainder); - //Record the final results. - Remainder = remainder; - Quotient = quotient; - Divisor = divisor; + if (divisor == 0) { + fault = new DivideByZero; + } else { + divide(dividend, divisor, quotient, remainder); + //Record the final results. + Remainder = remainder; + Quotient = quotient; + Divisor = divisor; + } ''' # Step divide @@ -535,7 +538,9 @@ let {{ int remaining = op2; //If we overshot, do nothing. This lets us unrool division loops a //little. - if (remaining) { + if (divisor == 0) { + fault = new DivideByZero; + } else if (remaining) { if (divisor & (ULL(1) << 63)) { while (remaining && !(dividend & (ULL(1) << 63))) { dividend = (dividend << 1) | |