ref: 88505bff06822e2d6313de477874a7a816935ea7
parent: fefc7b526da85c55d3cad66bfe8b565ac40f78d1
author: cinap_lenrek <[email protected]>
date: Mon Feb 3 17:55:45 EST 2014
realemu: cleanup opidiv no need for switch here, just calculate the values. also fixes 6l warning about uninitialized min/max (compiler assumes none of the case statements could match).
--- a/sys/src/cmd/aux/realemu/xec.c
+++ b/sys/src/cmd/aux/realemu/xec.c
@@ -799,21 +799,8 @@
q = n/d;
r = n%d;
- /* check for overflow based on operand size */
- switch(s) {
- case 8:
- min = (char)0x80;
- max = 0x7F;
- break;
- case 16:
- min = (short)0x8000;
- max = 0x7FFF;
- break;
- case 32:
- min = (long)0x80000000;
- max = 0x7FFFFFFF;
- break;
- }
+ max = sign(s)-1;
+ min = ~max;
if(q > max || q < min)
trap(cpu, EDIV0);