static List<CStatement> And_C(uint pc, uint instruction) { Instruction i = new Instruction(instruction); /* op1 & op2 */ CStatement stat = new CStatement(CStatement.Kinds.And, RegName(i.RS()), RegName(i.RB())); /* dest = expr */ CStatement ass = new CStatement(CStatement.Kinds.Assignment, RegName(i.RA()), stat); List<CStatement> stats = new List<CStatement>(); stats.Add(ass); if (i.RC()) stats.Add(new CStatement(CStatement.Kinds.Assignment, "cr0", RegName(i.RA()))); return stats; }
static List<CStatement> Add_C(uint pc, uint instruction) { Instruction i = new Instruction(instruction); /* op1 + op2 */ CStatement stat = new CStatement(CStatement.Kinds.Addition, RegName(i.RA()), RegName(i.RB())); /* dest = expr */ CStatement ass = new CStatement(CStatement.Kinds.Assignment, RegName(i.RD()), stat); List<CStatement> stats = new List<CStatement>(); stats.Add(ass); if (i.OE()) MessageBox.Show("This instruction sets the O bit. I don't know how to translate it! Ignoring."); if (i.RC()) stats.Add(new CStatement(CStatement.Kinds.Assignment, "cr0", RegName(i.RD()))); return stats; }
static List<CStatement> Lbzx_C(uint pc, uint instruction) { Instruction i = new Instruction(instruction); CStatement stat = new CStatement(CStatement.Kinds.Assignment, RegName(i.RD())); stat.OperandSizes = CStatement.Sizes.Byte; if (i.RA() != 0) { if (i.RB() != 0) stat.Op2 = new CStatement.COperand(RegName(i.RA()), RegName(i.RB())); else stat.Op2 = new CStatement.COperand(RegName(i.RA()), 0); } else stat.Op2 = new CStatement.COperand(RegName(i.RB()), 0); List<CStatement> stats = new List<CStatement>(); stats.Add(stat); return stats; }
static List<CStatement> Cmp_C(uint pc, uint instruction) { Instruction i = new Instruction(instruction); CStatement stat = new CStatement(CStatement.Kinds.Subtraction, RegName(i.RA()), RegName(i.RB())); CStatement ass = new CStatement(CStatement.Kinds.Assignment, "cr" + i.CRFD(), stat); if (!i.CmpLong()) ass.OperandSizes = stat.OperandSizes = CStatement.Sizes.Int; List<CStatement> stats = new List<CStatement>(); stats.Add(ass); return stats; }
static List<CStatement> Or_C(uint pc, uint instruction) { Instruction i = new Instruction(instruction); CStatement stat; if (i.RS() == 0 && i.RB() != 0) stat = new CStatement(CStatement.Kinds.Assignment, RegName(i.RA()), RegName(i.RB())); else if (i.RB() == 0 && i.RS() != 0) stat = new CStatement(CStatement.Kinds.Assignment, RegName(i.RA()), RegName(i.RS())); else if (i.RS() == i.RB()) { if (i.RS() != 0) stat = new CStatement(CStatement.Kinds.Assignment, RegName(i.RA()), RegName(i.RS())); else stat = new CStatement(CStatement.Kinds.Assignment, RegName(i.RA()), 0); } else { CStatement or = new CStatement(CStatement.Kinds.Or, RegName(i.RS()), RegName(i.RB())); or.OperandSizes = CStatement.Sizes.Long; stat = new CStatement(CStatement.Kinds.Assignment, RegName(i.RA()), or); } stat.OperandSizes = CStatement.Sizes.Long; List<CStatement> stats = new List<CStatement>(); stats.Add(stat); if (i.RC()) stats.Add(new CStatement(CStatement.Kinds.Assignment, "cr0", RegName(i.RA()))); return stats; }