- printf(" LO%s = SIGNEXTEND(((%sint)op1 / (%sint)op2),32);\n",
- (pipe1 ? "1" : ""),
- (boolU ? "unsigned " : ""),(boolU ? "unsigned " : ""));
- printf(" HI%s = SIGNEXTEND(((%sint)op1 %c (%sint)op2),32);\n",
- (pipe1 ? "1" : ""),
- (boolU ? "unsigned " : ""),'%',(boolU ? "unsigned " : ""));
+ printf(" %sint d1 = op1;\n", (boolU ? "unsigned " : ""));
+ printf(" %sint d2 = op2;\n", (boolU ? "unsigned " : ""));
+ printf(" if (d2 == 0)\n");
+ printf(" {\n");
+ printf(" LO%s = SIGNEXTEND(0x80000000,32);\n",pipe);
+ printf(" HI%s = SIGNEXTEND(0,32);\n", pipe);
+ printf(" }\n");
+ printf(" else if (d2 == -1 && d1 == 0x80000000)\n");
+ printf(" {\n");
+ printf(" LO%s = SIGNEXTEND(0x80000000,32);\n",pipe);
+ printf(" HI%s = SIGNEXTEND(0,32);\n", pipe);
+ printf(" }\n");
+ printf(" else\n");
+ printf(" {\n");
+ printf(" LO%s = SIGNEXTEND((d1 / d2),32);\n", pipe);
+ printf(" HI%s = SIGNEXTEND((d1 %% d2),32);\n", pipe);
+ printf(" }\n");