public static int DecompileTest(bool R1, BaseInstruction Cur, StringBuilder Buf, Stub OwnerStub, int Index) { String CmpTarget = R1 ? "R1" : OwnerStub.DecompileInstruction_A(Cur); bool TestVal = Cur.C != 0; BaseInstruction BI = OwnerStub.Instructions[Index + 1]; Buf.Append(String.Format("R1\t\t= {0}\n", CmpTarget)); if (BI.GetFullName().Contains("_JMP")) { if (TestVal) { Buf.Append(String.Format("if ({0}) goto {1}", CmpTarget, Index + BI.B + 1 + 1)); } else { Buf.Append(String.Format("if (not ({0})) goto {1}", CmpTarget, Index + BI.B + 1 + 1)); } Index++; return(Index); } if (TestVal) { Buf.Append(String.Format("if (not({0})) goto {1}", CmpTarget, Index + 2)); } else { Buf.Append(String.Format("if ({0}) goto {1}", CmpTarget, Index + 2)); } return(Index); }
public static int DecompileExpressionStatement(String ExprLogic, BaseInstruction Cur, StringBuilder Buf, Stub OwnerStub, int Index) { bool AVal = Cur.A != 0; String IfStatement = ""; BaseInstruction BI = OwnerStub.Instructions[Index + 1]; if (BI.GetFullName().Contains("_JMP")) { if (AVal) { IfStatement = String.Format("if ({0} {2} {1})", OwnerStub.DecompileInstruction_B(Cur), OwnerStub.DecompileInstruction_C(Cur), ExprLogic); } else { IfStatement = String.Format("if (not({0} {2} {1}))", OwnerStub.DecompileInstruction_B(Cur), OwnerStub.DecompileInstruction_C(Cur), ExprLogic); } IfStatement += String.Format(" goto {0}", Index + BI.B + 1 + 1); Index++; } else { if (AVal) { IfStatement = String.Format("if (not({0} {2} {1}))", OwnerStub.DecompileInstruction_B(Cur), OwnerStub.DecompileInstruction_C(Cur), ExprLogic); } else { IfStatement = String.Format("if ({0} {2} {1})", OwnerStub.DecompileInstruction_B(Cur), OwnerStub.DecompileInstruction_C(Cur), ExprLogic); } IfStatement += String.Format(" goto {0}", Index + 2); } Buf.Append(IfStatement); return(Index); }