public static void FSUB(string fir, string sec) { SoReg rf = reg[fir] as SoReg; SoReg rs = reg[sec] as SoReg; if (rf.val < rs.val) { string s = fir; fir = sec; sec = s; } if (rf.val < 0 && rs.val > 0) { Visual.VisualCommandFAdd(1, fir, sec); } else if (rf.val > 0 && rs.val < 0) { Visual.VisualCommandFAdd(0, fir, sec); } else if (rf.val < 0 && rs.val < 0) { Visual.VisualCommandFSub(1, fir, sec); } else { Visual.VisualCommandFSub(0, fir, sec); } double ans = rf.val - rs.val; rf.In(ans); }
public static void FMUL(string fir, string sec) { Visual.VisualCommandFMul(fir, sec); SoReg rf = reg[fir] as SoReg; SoReg rs = reg[sec] as SoReg; double ans = rf.val * rs.val; rf.In(ans); }
public static void FDIV(string fir, string sec) { SoReg rf = reg[fir] as SoReg; SoReg rs = reg[sec] as SoReg; if (Math.Abs(rs.val) <= 0.00000001) { Console.WriteLine("Divide by zero!"); return; } Visual.VisualCommandFDiv(fir, sec); double ans = rf.val / rs.val; rf.In(ans); }
public static void FADD(string fir, string sec) { SoReg rf = reg[fir] as SoReg; SoReg rs = reg[sec] as SoReg; if (rf.val < 0 && rs.val > 0) { Visual.VisualCommandFSub(1, fir, sec); } else if (rf.val > 0 && rs.val < 0) { Visual.VisualCommandFSub(0, fir, sec); } else { Visual.VisualCommandFAdd(1, fir, sec); } double ans = rf.val + rs.val; rf.In(ans); }