//public static string GetSourceAsString( this IInstructionData aThis ) //{ // string xDest = ""; // if( ( aThis.SourceValue.HasValue || aThis.SourceRef != null ) && // aThis.SourceIsIndirect && // aThis.SourceReg != null ) // { // throw new Exception( "[Scale*index+base] style addressing not supported at the moment" ); // } // if( aThis.SourceRef != null ) // { // xDest = aThis.SourceRef.ToString(); // } // else // { // if( aThis.SourceReg != null ) // { // xDest = Registers.GetRegisterName( aThis.SourceReg.Value ); // } // else // { // xDest = "0x" + aThis.SourceValue.GetValueOrDefault().ToString( "X" ).ToUpperInvariant(); // } // } // if( aThis.SourceDisplacement != 0 ) // { // xDest += " + " + aThis.SourceDisplacement; // } // if( aThis.SourceIsIndirect ) // { // return "[" + xDest + "]"; // } // else // { // return xDest; // } //} //public static string GetDestinationAsString( this IInstructionData aThis ) //{ // string xDest = ""; // if( ( aThis.DestinationValue.HasValue || aThis.DestinationRef != null ) && // aThis.DestinationIsIndirect && // aThis.DestinationReg != null ) // { // throw new Exception( "[Scale*index+base] style addressing not supported at the moment" ); // } // if( aThis.DestinationRef != null ) // { // xDest = aThis.DestinationRef.ToString(); // } // else // { // if( aThis.DestinationReg != null ) // { // xDest = Registers.GetRegisterName( aThis.DestinationReg.Value ); // } // else // { // xDest = "0x" + aThis.DestinationValue.GetValueOrDefault().ToString( "X" ).ToUpperInvariant(); // } // } // if( aThis.DestinationDisplacement != 0 ) // { // if( aThis.DestinationDisplacement > 255 ) // { // xDest += " + 0x" + aThis.DestinationDisplacement.ToString( "X" ); // } // else // { // xDest += " + " + aThis.DestinationDisplacement; // } // } // if( aThis.DestinationIsIndirect ) // { // return String.Intern( "[" + xDest + "]" ); // } // else // { // return String.Intern( xDest ); // } //} //public static void DetermineSize( this IInstructionData aThis, IInstructionData aThis2, byte aSize ) //{ // if( aSize == 0 ) // { // if( aThis.DestinationReg != null && !aThis.DestinationIsIndirect ) // { // if( Registers.Is16Bit( aThis.DestinationReg.Value ) ) // { // aThis2.Size = ( InstructionSize )16; // } // else // { // if( Registers.Is32Bit( aThis.DestinationReg.Value ) ) // { // aThis2.Size = ( InstructionSize )32; // } // else // { // aThis2.Size = ( InstructionSize )8; // } // } // return; // } // if( aThis.DestinationRef != null && !aThis.DestinationIsIndirect ) // { // aThis2.Size = ( InstructionSize )32; // return; // } // } //} public static string GetMnemonic(this ConditionalTestEnum aThis) { switch (aThis) { case ConditionalTestEnum.Overflow: return("o"); case ConditionalTestEnum.NoOverflow: return("no"); case ConditionalTestEnum.Below: return("b"); case ConditionalTestEnum.NotBelow: return("nb"); case ConditionalTestEnum.Equal: return("e"); case ConditionalTestEnum.NotEqual: return("ne"); case ConditionalTestEnum.BelowOrEqual: return("be"); case ConditionalTestEnum.NotBelowOrEqual: return("nbe"); case ConditionalTestEnum.Sign: return("s"); case ConditionalTestEnum.NotSign: return("ns"); case ConditionalTestEnum.Parity: return("p"); case ConditionalTestEnum.NotParity: return("np"); case ConditionalTestEnum.LessThan: return("l"); case ConditionalTestEnum.NotLessThan: return("nl"); case ConditionalTestEnum.LessThanOrEqualTo: return("le"); case ConditionalTestEnum.NotLessThanOrEqualTo: return("nle"); default: throw new NotImplementedException(); } }
public void EmitBooleanBranch(bool v, Label truecase, ConditionalTestEnum tr, ConditionalTestEnum fls) { if (v) { EmitInstruction(new ConditionalJump() { Condition = tr, DestinationLabel = truecase.Name }); } else { EmitInstruction(new ConditionalJump() { Condition = fls, DestinationLabel = truecase.Name }); } }
public void EmitBoolean(RegistersEnum rg, ConditionalTestEnum tr, ConditionalTestEnum fls) { // EmitInstruction(new Xor() { SourceReg = ag.GetHolder(rg), DestinationReg = ag.GetHolder(rg), Size = 80 }); EmitInstruction(new ConditionalSet() { Condition = tr, DestinationReg = GetLow(rg), Size = 80 }); EmitInstruction(new MoveZeroExtend() { SourceReg = GetLow(rg), DestinationReg = ag.GetHolder(rg), Size = 80 }); /* * EmitInstruction(new ConditionalMove() { Condition = tr, DestinationReg = rg, Size = 80, SourceValue = TRUE }); * EmitInstruction(new ConditionalMove() { Condition = fls, DestinationReg = rg, Size = 80, SourceValue = 0 }); * * */ }
public void EmitBooleanWithJump(RegistersEnum rg, ConditionalTestEnum TR) { string lbname = EmitContext.GenerateLabelName(LabelType.BOOL_EXPR); Label truelb = DefineLabel(lbname + "_TRUE"); Label falselb = DefineLabel(lbname + "_FALSE"); Label boolexprlb = DefineLabel(lbname + "_END"); // jumps EmitInstruction(new ConditionalJump() { Condition = TR, DestinationLabel = truelb.Name }); EmitInstruction(new Jump() { DestinationLabel = falselb.Name }); // false // emit true and false // true MarkLabel(truelb); EmitInstruction(new Mov() { DestinationReg = EmitContext.A, SourceValue = TRUE, Size = 8 }); EmitInstruction(new Jump() { DestinationLabel = boolexprlb.Name }); // exit // false MarkLabel(falselb); EmitInstruction(new Mov() { DestinationReg = EmitContext.A, SourceValue = 0, Size = 8 }); // mark exit MarkLabel(boolexprlb); }
public static void Jump(ConditionalTestEnum condition, string label) { new ConditionalJump { Condition = condition, DestinationLabel = label }; }