public void Emit(Format5OpCode opCode, Register rd, Register rs, string nopExplanation=null) { string fluentComment; var rsIsHigh=rs is HighRegister; var rdIsHigh=rd is HighRegister; if(opCode==Format5OpCode.BX) { //rd is ignored on BX instruction rd=Register.R0; fluentComment="BX "+rs; } else if(!rsIsHigh && !rdIsHigh) { throw new Exception("illegal use of this instruction"); } else if(rd.EqualTo(rs)) { fluentComment="NOP"; } else { fluentComment=opCode.ToHumanReadable().MyConcat(" ", rd, ",", rs); } if(nopExplanation!=null) { fluentComment=fluentComment+" ("+nopExplanation+")"; } var maskedRs=rs.Index&7; var maskedRd=rd.Index&7; var h1Bits=rdIsHigh ? 1 : 0; var h2Bits=rsIsHigh ? 1 : 0; EmitHelper(rd, 5, fluentComment, 17, 6, (int)opCode, 2, h1Bits, 1, h2Bits, 1, maskedRs, 3, maskedRd, 3); }
public void Emit(Format5OpCode opCode, Register rd, Register rs, string nopExplanation = null) { string fluentComment; var rsIsHigh = rs is HighRegister; var rdIsHigh = rd is HighRegister; if (opCode == Format5OpCode.BX) { //rd is ignored on BX instruction rd = Register.R0; fluentComment = "BX " + rs; } else if (!rsIsHigh && !rdIsHigh) { throw new Exception("illegal use of this instruction"); } else if (rd.EqualTo(rs)) { fluentComment = "NOP"; } else { fluentComment = opCode.ToHumanReadable().MyConcat(" ", rd, ",", rs); } if (nopExplanation != null) { fluentComment = fluentComment + " (" + nopExplanation + ")"; } var maskedRs = rs.Index & 7; var maskedRd = rd.Index & 7; var h1Bits = rdIsHigh ? 1 : 0; var h2Bits = rsIsHigh ? 1 : 0; EmitHelper(rd, 5, fluentComment, 17, 6, (int)opCode, 2, h1Bits, 1, h2Bits, 1, maskedRs, 3, maskedRd, 3); }
public static string ToHumanReadable(this Format5OpCode opCode) { return("ADDCMPMOVBX ".Substring((int)opCode * 3, 3)); }