private void doRoot(uint inst) { debug += "LW:\tR1 = " + binaryToStr(r1) + " = "; r1 = LibRcs.squareRootFp(r1 << 10) >> 10; debug += binaryToStr(r1); return; }
/* * private int mul(int a, int b) * { * int i; * int tmp; * tmp = 0; * for (i = 0; i < 17; i++) * { * if ((b & 0x20000) == 0x20000) * { * tmp += a; * } * b <<= 1; * a >>= 1; * } * return tmp; * } */ private void doDivision(uint inst) { int exp1, exp2, exp3; debug += "LI:\tR1 = " + binaryToStr(r1) + " / " + binaryToStr(r2) + " = "; exp1 = (int)((r1 >> 14) & 0x7f); exp2 = (int)((r2 >> 14) & 0x7f); if (exp1 == 0x40 && exp2 == 0x40) { flags |= E_DIVZERO | E_ALARM; stopped = true; } if (exp1 == 0x3f && exp2 == 0x3f) { flags |= E_DIVINF | E_ALARM; stopped = true; } r1 = LibRcs.divFp(r1 << 10, r2 << 10) >> 10; r2 = 0; exp3 = (int)((r1 >> 14) & 0x7f); if (exp1 != 0x40 && exp2 != 0x40 && exp3 == 0x40) { flags |= E_ALARM; flags |= E_ZERO; stopped = true; } if (exp1 != 0x3f && exp2 != 0x3f && exp3 == 0x3f) { flags |= E_ALARM; flags |= E_INF; stopped = true; } debug += binaryToStr(r1); }
private void doMultiplication(uint inst) { int exp1, exp2, exp3; debug += "LM:\tR1 = " + binaryToStr(r1) + " * " + binaryToStr(r2) + " = "; exp1 = (int)((r1 >> 14) & 0x7f); exp2 = (int)((r2 >> 14) & 0x7f); if (exp1 == 0x40 && exp2 == 0x3f) { flags |= E_ZEROMULINF | E_ALARM; stopped = true; } if (exp1 == 0x3f && exp2 == 0x40) { flags |= E_ZEROMULINF | E_ALARM; stopped = true; } r1 = LibRcs.mulFp((uint)(r1 << 10), (uint)(r2 << 10)) >> 10; exp3 = (int)((r1 >> 14) & 0x7f); if (exp1 != 0x40 && exp2 != 0x40 && exp3 == 0x40) { flags |= E_ALARM; flags |= E_ZERO; stopped = true; } if (exp1 != 0x3f && exp2 != 0x3f && exp3 == 0x3f) { flags |= E_ALARM; flags |= E_INF; stopped = true; } debug += binaryToStr(r1); return; }
private void test(String s) { int i; String str; uint t = LibRcs.strToSingle(s); str = LibRcs.singleToStr(t); if ((t & 0x80000000) == 0x80000000) { debugOutput.AppendText("- "); } else { debugOutput.AppendText("+ "); } t <<= 1; for (i = 0; i < 7; i++) { if ((t & 0x80000000) == 0x80000000) { debugOutput.AppendText("1"); } else { debugOutput.AppendText("0"); } t <<= 1; } debugOutput.AppendText(" 1."); for (i = 0; i < 24; i++) { if ((t & 0x80000000) == 0x80000000) { debugOutput.AppendText("1"); } else { debugOutput.AppendText("0"); } t <<= 1; } debugOutput.AppendText(" = " + str + "\r\n"); }
private void doAddition(uint inst, char mode) { int exp1, exp2, exp3; Boolean sign; if (mode == 'A') { debug += "LS1:\tR1 = " + binaryToStr(r1) + " + " + binaryToStr(r2) + " = "; } if (mode == 'S') { debug += "LS2:\tR1 = " + binaryToStr(r1) + " + " + binaryToStr(r2) + " = "; } exp1 = (int)((r1 >> 14) & 0x7f); exp2 = (int)((r2 >> 14) & 0x7f); sign = ((r1 & 0x200000) == (r2 & 0x200000)) ? true : false; if (exp1 == 0x3f && exp2 == 0x3f) { flags |= E_ALARM; flags |= (exp1 == exp2) ? E_ADDINF : E_INF; stopped = true; } r1 = LibRcs.addFp(r1 << 10, r2 << 10) >> 10; exp3 = (int)((r1 >> 14) & 0x7f); if (exp1 != 0x40 && exp2 != 0x40 && exp3 == 0x40 && sign) { flags |= E_ALARM; flags |= E_ZERO; stopped = true; } if (exp1 != 0x3f && exp2 != 0x3f && exp3 == 0x3f) { flags |= E_ALARM; flags |= E_INF; stopped = true; } debug += binaryToStr(r1); }