本文整理汇总了C#中Mosa.Runtime.CompilerFramework.Operands.RegisterOperand类的典型用法代码示例。如果您正苦于以下问题:C# RegisterOperand类的具体用法?C# RegisterOperand怎么用?C# RegisterOperand使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
RegisterOperand类属于Mosa.Runtime.CompilerFramework.Operands命名空间,在下文中一共展示了RegisterOperand类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CreateISRMethods
/// <summary>
/// Creates the ISR methods.
/// </summary>
/// <param name="compiler">The compiler.</param>
private void CreateISRMethods(AssemblyCompiler compiler)
{
// Create Interrupt Service Routines (ISR)
RuntimeMethod InterruptMethod = compiler.Assembly.EntryPoint; // TODO: replace with another entry point
SigType I1 = new SigType(CilElementType.I1);
SigType I4 = new SigType(CilElementType.I4);
RegisterOperand eax = new RegisterOperand(I4, GeneralPurposeRegister.EAX);
for (int i = 0; i <= 256; i++) {
InstructionSet set = new InstructionSet(100);
Context ctx = new Context(set, -1);
ctx.SetInstruction(CPUx86.Instruction.CliInstruction);
if ((i != 8) && (i < 10 || i > 14)) // For IRQ 8, 10, 11, 12, 13, 14 the cpu automatically pushed the error code
ctx.AppendInstruction(CPUx86.Instruction.PushInstruction, null, new ConstantOperand(I4, 0x0));
ctx.AppendInstruction(CPUx86.Instruction.PushadInstruction);
ctx.AppendInstruction(CPUx86.Instruction.PushInstruction, null, new ConstantOperand(I4, i));
// TODO: Set method parameters
ctx.AppendInstruction(CPUx86.Instruction.CallInstruction, InterruptMethod);
ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, eax);
ctx.AppendInstruction(CPUx86.Instruction.PopadInstruction);
ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, eax);
ctx.AppendInstruction(CPUx86.Instruction.StiInstruction);
//ctx.AppendInstruction(CPUx86.Instruction.IRetdInstruction);
CompilerGeneratedMethod method = LinkTimeCodeGenerator.Compile(compiler, @"InterruptISR" + i.ToString(), set);
}
}
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:33,代码来源:InterruptStage.cs
示例2: CreateISRMethods
/// <summary>
/// Creates the ISR methods.
/// </summary>
/// <param name="compiler">The compiler.</param>
private void CreateISRMethods(AssemblyCompiler compiler)
{
// Get RuntimeMethod for the Mosa.Kernel.X86.IDT.InterruptHandler
RuntimeType rt = RuntimeBase.Instance.TypeLoader.GetType(@"Mosa.Kernel.X86.IDT");
RuntimeMethod InterruptMethod = FindMethod(rt, "InterruptHandler");
SigType I1 = new SigType(CilElementType.I1);
SigType I2 = new SigType(CilElementType.I4);
RegisterOperand ecx1 = new RegisterOperand(I1, GeneralPurposeRegister.ECX);
RegisterOperand ecx2 = new RegisterOperand(I2, GeneralPurposeRegister.ECX);
for (int i = 0; i <= 256; i++) {
InstructionSet set = new InstructionSet(100);
Context ctx = new Context(set, -1);
ctx.AppendInstruction(CPUx86.Instruction.CliInstruction);
ctx.AppendInstruction(CPUx86.Instruction.PushadInstruction);
if ((i != 8) && (i < 10 || i > 14)) // For IRQ 8, 10, 11, 12, 13, 14 the cpu automatically pushed the error code
ctx.AppendInstruction(CPUx86.Instruction.PushInstruction, null, new ConstantOperand(I1, 0x0));
ctx.AppendInstruction(CPUx86.Instruction.PushInstruction, null, new ConstantOperand(I2, i));
ctx.AppendInstruction(CPUx86.Instruction.CallInstruction, InterruptMethod);
// TODO: Replace next two instructions with add esp, 5 ;Stack clearing
ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, ecx2);
ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, ecx1);
ctx.AppendInstruction(CPUx86.Instruction.PopadInstruction);
ctx.AppendInstruction(CPUx86.Instruction.StiInstruction);
ctx.AppendInstruction(CPUx86.Instruction.IRetdInstruction);
CompilerGeneratedMethod method = LinkTimeCodeGenerator.Compile(compiler, @"InterruptISR" + i.ToString(), set);
}
}
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:36,代码来源:InterruptBuilderStage.cs
示例3: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
Operand result = context.Result;
RegisterOperand imm = new RegisterOperand(new SigType(CilElementType.U4), GeneralPurposeRegister.EAX);
context.SetInstruction(IR.Instruction.MoveInstruction, imm, new RegisterOperand(new SigType(CilElementType.U4), _control));
context.AppendInstruction(IR.Instruction.MoveInstruction, result, imm);
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:14,代码来源:GetControlRegisterBase.cs
示例4: RegisterOperand
/// <summary>
/// Visitation function for <see cref="IR.IIRVisitor.AddressOfInstruction"/> instruction.
/// </summary>
/// <param name="ctx">The context.</param>
void IR.IIRVisitor.AddressOfInstruction(Context ctx)
{
Operand opRes = ctx.Result;
RegisterOperand eax = new RegisterOperand (opRes.Type, GeneralPurposeRegister.EAX);
ctx.Result = eax;
ctx.ReplaceInstructionOnly (CPUx86.Instruction.LeaInstruction);
// ctx.Ignore = true;
ctx.AppendInstruction (CPUx86.Instruction.MovInstruction, opRes, eax);
}
开发者ID:hj1980,项目名称:Mosa,代码行数:13,代码来源:IRTransformationStage.cs
示例5: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
public void ReplaceIntrinsicCall(Context context)
{
Operand operand1 = context.Operand1;
RegisterOperand imm = new RegisterOperand(new SigType(CilElementType.U4), GeneralPurposeRegister.EAX);
context.SetInstruction(IR.Instruction.MoveInstruction, imm, operand1);
context.AppendInstruction(IR.Instruction.MoveInstruction, new RegisterOperand(new SigType(CilElementType.U4), _control), imm);
}
开发者ID:davidbjornn,项目名称:MOSA-Project,代码行数:13,代码来源:SetControlRegisterBase.cs
示例6: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
Operand result = context.Result;
RegisterOperand tmp = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.Ptr), GeneralPurposeRegister.EDX);
MemoryOperand operand = new MemoryOperand(context.Operand1.Type, GeneralPurposeRegister.EDX, new System.IntPtr(0));
context.SetInstruction(CPUx86.Instruction.MovInstruction, tmp, context.Operand1);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, result, operand);
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:15,代码来源:Get.cs
示例7: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
SigType I4 = new SigType(CilElementType.I4);
RegisterOperand esp = new RegisterOperand(I4, GeneralPurposeRegister.ESP);
context.SetInstruction(CPUx86.Instruction.MovInstruction, esp, context.Operand1);
context.AppendInstruction(CPUx86.Instruction.PopadInstruction);
context.AppendInstruction(CPUx86.Instruction.AddInstruction, esp, new ConstantOperand(I4, 0x08));
context.AppendInstruction(CPUx86.Instruction.StiInstruction);
context.AppendInstruction(CPUx86.Instruction.IRetdInstruction);
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:16,代码来源:SwitchTask.cs
示例8: ThreeTwoAddressConversion
/// <summary>
/// Converts the given instruction from three address format to a two address format.
/// </summary>
/// <param name="ctx">The conversion context.</param>
private static void ThreeTwoAddressConversion(Context ctx)
{
Operand result = ctx.Result;
Operand op1 = ctx.Operand1;
Operand op2 = ctx.Operand2;
if (ctx.Instruction is IR.FloatingPointCompareInstruction)
return;
if (ctx.Instruction is CIL.MulInstruction /*|| ctx.Instruction is CIL.DivInstruction*/)
if (!(op1 is ConstantOperand) && (op2 is ConstantOperand))
{
Operand temp = op1;
op1 = op2;
op2 = temp;
}
// Create registers for different data types
RegisterOperand eax = new RegisterOperand(op1.Type, op1.StackType == StackTypeCode.F ? (Register)SSE2Register.XMM0 : GeneralPurposeRegister.EAX);
RegisterOperand storeOperand = new RegisterOperand(result.Type, result.StackType == StackTypeCode.F ? (Register)SSE2Register.XMM0 : GeneralPurposeRegister.EAX);
// RegisterOperand eaxL = new RegisterOperand(op1.Type, GeneralPurposeRegister.EAX);
ctx.Result = storeOperand;
ctx.Operand1 = op2;
ctx.Operand2 = null;
ctx.OperandCount = 1;
if (op1.StackType != StackTypeCode.F)
{
if (IsSigned(op1) && !(op1 is ConstantOperand))
ctx.InsertBefore().SetInstruction(IR.Instruction.SignExtendedMoveInstruction, eax, op1);
else if (IsUnsigned(op1) && !(op1 is ConstantOperand))
ctx.InsertBefore().SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, eax, op1);
else
ctx.InsertBefore().SetInstruction(CPUx86.Instruction.MovInstruction, eax, op1);
}
else
{
if (op1.Type.Type == CilElementType.R4)
{
if (op1 is ConstantOperand)
{
Context before = ctx.InsertBefore();
before.SetInstruction(CPUx86.Instruction.MovInstruction, eax, op1);
before.AppendInstruction(CPUx86.Instruction.Cvtss2sdInstruction, eax, eax);
}
else
ctx.InsertBefore().SetInstruction(CPUx86.Instruction.Cvtss2sdInstruction, eax, op1);
}
else
ctx.InsertBefore().SetInstruction(CPUx86.Instruction.MovInstruction, eax, op1);
}
ctx.AppendInstruction(CPUx86.Instruction.MovInstruction, result, eax);
}
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:58,代码来源:AddressModeConversionStage.cs
示例9: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
public void ReplaceIntrinsicCall(Context context)
{
Operand result = context.Result;
Operand operand = context.Operand1;
RegisterOperand eax = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I4), GeneralPurposeRegister.EAX);
RegisterOperand ecx = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I4), GeneralPurposeRegister.ECX);
RegisterOperand reg = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I4), GeneralPurposeRegister.EBX);
context.SetInstruction(CPUx86.Instruction.MovInstruction, eax, operand);
context.AppendInstruction(CPUx86.Instruction.XorInstruction, ecx, ecx);
context.AppendInstruction(CPUx86.Instruction.CpuIdEbxInstruction);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, result, reg);
}
开发者ID:hj1980,项目名称:MOSA-Project,代码行数:16,代码来源:CpuIdEbx.cs
示例10: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
Operand result = context.Result;
SigType u4 = new SigType(CilElementType.U4);
RegisterOperand eax = new RegisterOperand(u4, GeneralPurposeRegister.EAX);
context.SetInstruction(CPUx86.Instruction.PopInstruction, eax);
context.AppendInstruction(CPUx86.Instruction.AddInstruction, eax, new RegisterOperand(u4, GeneralPurposeRegister.ESP));
context.AppendInstruction(CPUx86.Instruction.MovInstruction, eax, new MemoryOperand(u4, GeneralPurposeRegister.EAX, new IntPtr(0)));
context.AppendInstruction(CPUx86.Instruction.MovInstruction, result, eax);
context.AppendInstruction(CPUx86.Instruction.PushInstruction, null, eax);
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:17,代码来源:GetEip.cs
示例11: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
public void ReplaceIntrinsicCall(Context context)
{
Operand operand1 = context.Operand1;
Operand operand2 = context.Operand2;
RegisterOperand edx = new RegisterOperand (operand1.Type, GeneralPurposeRegister.EDX);
RegisterOperand eax = new RegisterOperand (operand2.Type, GeneralPurposeRegister.EAX);
context.SetInstruction (CPUx86.Instruction.MovInstruction, edx, operand1);
context.AppendInstruction (CPUx86.Instruction.MovInstruction, eax, operand2);
context.AppendInstruction (CPUx86.Instruction.OutInstruction, null, edx, eax);
}
开发者ID:hj1980,项目名称:Mosa,代码行数:16,代码来源:OutInstruction.cs
示例12: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
Operand result = context.Result;
Operand operand1 = context.Operand1;
RegisterOperand edx = new RegisterOperand(operand1.Type, GeneralPurposeRegister.EDX);
RegisterOperand eax = new RegisterOperand(result.Type, GeneralPurposeRegister.EAX);
context.SetInstruction(CPUx86.Instruction.MovInstruction, edx, operand1);
context.AppendInstruction(CPUx86.Instruction.InInstruction, eax, edx);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, result, eax);
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:17,代码来源:In.cs
示例13: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
Operand dest = context.Operand1;
Operand value = context.Operand2;
RegisterOperand edx = new RegisterOperand(dest.Type, GeneralPurposeRegister.EDX);
RegisterOperand eax = new RegisterOperand(value.Type, GeneralPurposeRegister.EAX);
MemoryOperand memory = new MemoryOperand(new SigType(context.InvokeTarget.Signature.Parameters[1].Type), GeneralPurposeRegister.EDX, new IntPtr(0));
context.SetInstruction(CPUx86.Instruction.MovInstruction, edx, dest);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, eax, value);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, memory, eax);
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:18,代码来源:Set.cs
示例14: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
SigType u4 = new SigType(Runtime.Metadata.CilElementType.U4);
RegisterOperand ebp = new RegisterOperand(u4, GeneralPurposeRegister.EBP);
RegisterOperand esp = new RegisterOperand(u4, GeneralPurposeRegister.ESP);
RegisterOperand eax = new RegisterOperand(u4, GeneralPurposeRegister.EAX);
RegisterOperand ebx = new RegisterOperand(u4, GeneralPurposeRegister.EBX);
RegisterOperand ecx = new RegisterOperand(u4, GeneralPurposeRegister.ECX);
RegisterOperand edx = new RegisterOperand(u4, GeneralPurposeRegister.EDX);
RegisterOperand esi = new RegisterOperand(u4, GeneralPurposeRegister.ESI);
RegisterOperand edi = new RegisterOperand(u4, GeneralPurposeRegister.EDI);
context.SetInstruction(CPUx86.Instruction.PushInstruction, null, ebp);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ebp, esp);
context.AppendInstruction(CPUx86.Instruction.PushInstruction, null, ebx);
context.AppendInstruction(CPUx86.Instruction.PushInstruction, null, esi);
context.AppendInstruction(CPUx86.Instruction.PushInstruction, null, edi);
// Load register context
context.AppendInstruction(CPUx86.Instruction.MovInstruction, eax, new MemoryOperand(u4, GeneralPurposeRegister.ESP, new IntPtr(28)));
// Load exception handler
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ecx, new MemoryOperand(u4, GeneralPurposeRegister.ESP, new IntPtr(32)));
// Save EBP
context.AppendInstruction(CPUx86.Instruction.PushInstruction, null, ebp);
// Restore register values
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ebp, new MemoryOperand(u4, GeneralPurposeRegister.EAX, new IntPtr(24)));
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ebx, new MemoryOperand(u4, GeneralPurposeRegister.EAX, new IntPtr(4)));
context.AppendInstruction(CPUx86.Instruction.MovInstruction, esi, new MemoryOperand(u4, GeneralPurposeRegister.EAX, new IntPtr(16)));
context.AppendInstruction(CPUx86.Instruction.MovInstruction, edi, new MemoryOperand(u4, GeneralPurposeRegister.EAX, new IntPtr(20)));
// Align ESP
context.AppendInstruction(CPUx86.Instruction.MovInstruction, edx, esp);
context.AppendInstruction(CPUx86.Instruction.AndInstruction, esp, new ConstantOperand(u4, 0xFFFFFFF0u));
context.AppendInstruction(CPUx86.Instruction.SubInstruction, esp, new ConstantOperand(u4, 0x8u));
// Save original ESP
context.AppendInstruction(CPUx86.Instruction.PushInstruction, null, edx);
// Call catch handler
context.AppendInstruction(CPUx86.Instruction.CallInstruction, ecx);
// Restore registers
context.AppendInstruction(CPUx86.Instruction.PopInstruction, esp);
context.AppendInstruction(CPUx86.Instruction.PopInstruction, ebp);
context.AppendInstruction(CPUx86.Instruction.PopInstruction, esi);
context.AppendInstruction(CPUx86.Instruction.PopInstruction, edi);
context.AppendInstruction(CPUx86.Instruction.PopInstruction, ebx);
context.AppendInstruction(CPUx86.Instruction.LeaveInstruction);
context.AppendInstruction(CPUx86.Instruction.RetInstruction);
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:56,代码来源:CallFilter.cs
示例15: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
public void ReplaceIntrinsicCall(Context context)
{
if (!(context.Operand1 is ConstantOperand))
throw new InvalidOperationException();
Operand result = context.Result;
ControlRegister control;
switch ((int)(context.Operand1 as ConstantOperand).Value) {
case 0: control = ControlRegister.CR0; break;
case 2: control = ControlRegister.CR2; break;
case 3: control = ControlRegister.CR3; break;
case 4: control = ControlRegister.CR4; break;
default: throw new InvalidOperationException();
}
RegisterOperand imm = new RegisterOperand(new SigType(CilElementType.U4), GeneralPurposeRegister.EAX);
context.SetInstruction(IR.Instruction.MoveInstruction, imm, new RegisterOperand(new SigType(CilElementType.U4), control));
context.AppendInstruction(IR.Instruction.MoveInstruction, result, imm);
}
开发者ID:shanebrown99,项目名称:MOSA-Project,代码行数:26,代码来源:GetControlRegister.cs
示例16: ReplaceIntrinsicCall
/// <summary>
/// Replaces the instrinsic call site
/// </summary>
/// <param name="context">The context.</param>
/// <param name="typeSystem">The type system.</param>
public void ReplaceIntrinsicCall(Context context, ITypeSystem typeSystem)
{
MemoryOperand operand = new MemoryOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.Ptr), GeneralPurposeRegister.EAX, new System.IntPtr(0));
context.SetInstruction(CPUx86.Instruction.MovInstruction, new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.Ptr), GeneralPurposeRegister.EAX), context.Operand1);
context.AppendInstruction(CPUx86.Instruction.LgdtInstruction, null, operand);
RegisterOperand ax = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I2), GeneralPurposeRegister.EAX);
RegisterOperand ds = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I2), SegmentRegister.DS);
RegisterOperand es = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I2), SegmentRegister.ES);
RegisterOperand fs = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I2), SegmentRegister.FS);
RegisterOperand gs = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I2), SegmentRegister.GS);
RegisterOperand ss = new RegisterOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I2), SegmentRegister.SS);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ax, new ConstantOperand(new Mosa.Runtime.Metadata.Signatures.SigType(Mosa.Runtime.Metadata.CilElementType.I4), (int)0x00000010));
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ds, ax);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, es, ax);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, fs, ax);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, gs, ax);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, ss, ax);
context.AppendInstruction(CPUx86.Instruction.FarJmpInstruction);
context.AppendInstruction(CPUx86.Instruction.NopInstruction);
context.Previous.SetBranch(context.Offset);
}
开发者ID:illuminus86,项目名称:MOSA-Project,代码行数:28,代码来源:Lgdt.cs
示例17: HandleMemoryToMemoryOperation
private void HandleMemoryToMemoryOperation(Context ctx, Operand register, bool useStack)
{
Operand destination = ctx.Result;
Operand source = ctx.Operand1;
Debug.Assert(destination is MemoryOperand && source is MemoryOperand);
if (register == null)
register = new RegisterOperand(destination.Type, GeneralPurposeRegister.EDX);
ctx.Operand1 = register;
Context before = ctx.InsertBefore();
if (useStack) {
before.SetInstruction(CPUx86.Instruction.PushInstruction, null, register);
before.AppendInstruction(CPUx86.Instruction.MovInstruction, register, source);
}
else
before.SetInstruction(CPUx86.Instruction.MovInstruction, register, source);
if (useStack)
ctx.AppendInstruction(CPUx86.Instruction.PopInstruction, register);
}
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:24,代码来源:MemToMemConversionStage.cs
示例18: AssignRegister
/// <summary>
/// Assigns the operand to the register.
/// </summary>
/// <param name="rop">The register operand containing the register to assign.</param>
/// <param name="op">The operand assigned to the register.</param>
/// <param name="ctx">The context.</param>
private void AssignRegister(RegisterOperand rop, Operand op, Context ctx)
{
// Set the operand in the active operands list
int regIdx = rop.Register.Index;
Debug.Assert(_activeOperands[regIdx] == null, @"Register not free.");
_activeOperands[regIdx] = op;
_activeOpLastUse[regIdx] = ctx;
}
开发者ID:rtownsend,项目名称:MOSA-Project,代码行数:14,代码来源:SimpleRegisterAllocator.cs
示例19: ExpandURem
/// <summary>
/// Expands the urem instruction.
/// </summary>
/// <param name="context">The context.</param>
private void ExpandURem(Context context)
{
SigType U4 = new SigType(CilElementType.U4);
SigType U1 = new SigType(CilElementType.U1);
Operand op0H, op1H, op2H, op0L, op1L, op2L;
SplitLongOperand(context.Result, out op0L, out op0H);
SplitLongOperand(context.Operand1, out op1L, out op1H);
SplitLongOperand(context.Operand2, out op2L, out op2H);
RegisterOperand eax = new RegisterOperand(U4, GeneralPurposeRegister.EAX);
RegisterOperand ebx = new RegisterOperand(U4, GeneralPurposeRegister.EBX);
RegisterOperand edx = new RegisterOperand(U4, GeneralPurposeRegister.EDX);
RegisterOperand ecx = new RegisterOperand(U4, GeneralPurposeRegister.ECX);
RegisterOperand edi = new RegisterOperand(U4, GeneralPurposeRegister.EDI);
RegisterOperand esi = new RegisterOperand(U4, GeneralPurposeRegister.ESI);
Context[] newBlocks = CreateEmptyBlockContexts(context.Label, 11);
Context nextBlock = SplitContext(context, false);
// Determine sign of the result (edi = 0 if result is positive, non-zero
// otherwise) and make operands positive.
// xor edi,edi ; result sign assumed positive
//mov eax,HIWORD(DVND) ; hi word of a
//or eax,eax ; test to see if signed
//jge short L1 ; skip rest if a is already positive
//inc edi ; complement result sign flag bit
//mov edx,LOWORD(DVND) ; lo word of a
//neg eax ; make a positive
//neg edx
//sbb eax,0
//mov HIWORD(DVND),eax ; save positive value
//mov LOWORD(DVND),edx
context.SetInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[0].BasicBlock);
newBlocks[0].AppendInstruction(CPUx86.Instruction.PushInstruction, null, edi);
newBlocks[0].AppendInstruction(CPUx86.Instruction.PushInstruction, null, esi);
newBlocks[0].AppendInstruction(CPUx86.Instruction.PushInstruction, null, ebx);
newBlocks[0].AppendInstruction(CPUx86.Instruction.MovInstruction, eax, op2H);
newBlocks[0].AppendInstruction(CPUx86.Instruction.OrInstruction, eax, eax);
newBlocks[0].AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.NotEqual, newBlocks[2].BasicBlock);
newBlocks[0].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[1].BasicBlock);
LinkBlocks(newBlocks[0], newBlocks[2], newBlocks[1]);
newBlocks[1].AppendInstruction(CPUx86.Instruction.MovInstruction, ecx, op2L);
newBlocks[1].AppendInstruction(CPUx86.Instruction.MovInstruction, eax, op1H);
newBlocks[1].AppendInstruction(CPUx86.Instruction.XorInstruction, edx, edx);
newBlocks[1].AppendInstruction(CPUx86.Instruction.DirectDivisionInstruction, eax, ecx);
newBlocks[1].AppendInstruction(CPUx86.Instruction.MovInstruction, eax, op1L);
newBlocks[1].AppendInstruction(CPUx86.Instruction.DirectDivisionInstruction, eax, ecx);
newBlocks[1].AppendInstruction(CPUx86.Instruction.MovInstruction, eax, edx);
newBlocks[1].AppendInstruction(CPUx86.Instruction.XorInstruction, edx, edx);
newBlocks[1].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[10].BasicBlock);
LinkBlocks(newBlocks[1], newBlocks[10]);
// L1:
newBlocks[2].AppendInstruction(CPUx86.Instruction.MovInstruction, ecx, eax);
newBlocks[2].AppendInstruction(CPUx86.Instruction.MovInstruction, ebx, op2L);
newBlocks[2].AppendInstruction(CPUx86.Instruction.MovInstruction, edx, op1H);
newBlocks[2].AppendInstruction(CPUx86.Instruction.MovInstruction, eax, op1L);
newBlocks[2].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[3].BasicBlock);
LinkBlocks(newBlocks[2], newBlocks[3]);
// L3:
newBlocks[3].AppendInstruction(CPUx86.Instruction.ShrInstruction, ecx, new ConstantOperand(U1, 1));
newBlocks[3].AppendInstruction(CPUx86.Instruction.RcrInstruction, ebx, new ConstantOperand(U1, 1)); // RCR
newBlocks[3].AppendInstruction(CPUx86.Instruction.ShrInstruction, edx, new ConstantOperand(U1, 1));
newBlocks[3].AppendInstruction(CPUx86.Instruction.RcrInstruction, eax, new ConstantOperand(U1, 1));
newBlocks[3].AppendInstruction(CPUx86.Instruction.OrInstruction, ecx, ecx);
newBlocks[3].AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.NotEqual, newBlocks[3].BasicBlock);
newBlocks[3].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[4].BasicBlock);
LinkBlocks(newBlocks[3], newBlocks[3], newBlocks[4]);
newBlocks[4].AppendInstruction(CPUx86.Instruction.DirectDivisionInstruction, eax, ebx);
newBlocks[4].AppendInstruction(CPUx86.Instruction.MovInstruction, ecx, eax);
newBlocks[4].AppendInstruction(CPUx86.Instruction.MulInstruction, null, op2H);
newBlocks[4].AppendInstruction(CPUx86.Instruction.XchgInstruction, ecx, eax);
newBlocks[4].AppendInstruction(CPUx86.Instruction.MulInstruction, null, op2L);
newBlocks[4].AppendInstruction(CPUx86.Instruction.AddInstruction, edx, ecx);
newBlocks[4].AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.UnsignedLessThan, newBlocks[8].BasicBlock);
newBlocks[4].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[5].BasicBlock);
LinkBlocks(newBlocks[4], newBlocks[8], newBlocks[5]);
newBlocks[5].AppendInstruction(CPUx86.Instruction.DirectCompareInstruction, edx, op1H);
newBlocks[5].AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.UnsignedGreaterThan, newBlocks[8].BasicBlock);
newBlocks[5].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[6].BasicBlock);
LinkBlocks(newBlocks[5], newBlocks[8], newBlocks[6]);
newBlocks[6].AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.UnsignedLessThan, newBlocks[9].BasicBlock);
newBlocks[6].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[7].BasicBlock);
LinkBlocks(newBlocks[6], newBlocks[6], newBlocks[7]);
newBlocks[7].AppendInstruction(CPUx86.Instruction.DirectCompareInstruction, eax, op1L);
newBlocks[7].AppendInstruction(CPUx86.Instruction.BranchInstruction, IR.ConditionCode.UnsignedLessOrEqual, newBlocks[9].BasicBlock);
newBlocks[7].AppendInstruction(CPUx86.Instruction.JmpInstruction, newBlocks[3].BasicBlock);
LinkBlocks(newBlocks[7], newBlocks[9], newBlocks[3]);
// L4:
//.........这里部分代码省略.........
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:101,代码来源:LongOperandTransformationStage.cs
示例20: ExpandUnsignedMove
/// <summary>
/// Expands the unsigned move instruction for 64-bits.
/// </summary>
/// <param name="context">The context.</param>
private void ExpandUnsignedMove(Context context)
{
MemoryOperand op0 = context.Result as MemoryOperand;
Operand op1 = context.Operand1;
Debug.Assert(op0 != null, @"I8 not in a memory operand!");
SigType U4 = new SigType(CilElementType.U4);
Operand op0L, op0H, op1L, op1H;
SplitLongOperand(op0, out op0L, out op0H);
SplitLongOperand(op1, out op1L, out op1H);
RegisterOperand eax = new RegisterOperand(U4, GeneralPurposeRegister.EAX);
RegisterOperand edx = new RegisterOperand(U4, GeneralPurposeRegister.EDX);
switch (op1.Type.Type)
{
case CilElementType.Boolean:
context.SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, op0L, op1L);
context.AppendInstruction(IR.Instruction.LogicalXorInstruction, op0H, op0H, op0H);
break;
case CilElementType.U1:
context.SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, eax, op1L);
context.AppendInstruction(CPUx86.Instruction.CdqInstruction);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, op0L, eax);
context.AppendInstruction(IR.Instruction.LogicalXorInstruction, op0H, op0H, op0H);
break;
case CilElementType.U2: goto case CilElementType.U1;
case CilElementType.I4:
context.SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, eax, op1L);
context.AppendInstruction(CPUx86.Instruction.XorInstruction, edx, edx);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, op0L, eax);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, op0H, edx);
break;
case CilElementType.U4:
context.SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, eax, op1L);
context.AppendInstruction(CPUx86.Instruction.CdqInstruction);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, op0L, eax);
context.AppendInstruction(CPUx86.Instruction.MovInstruction, op0H, edx);
break;
case CilElementType.U8:
context.SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, op0L, op1L);
context.SetInstruction(IR.Instruction.ZeroExtendedMoveInstruction, op0H, op1H);
break;
case CilElementType.R4:
throw new NotSupportedException();
case CilElementType.R8:
throw new NotSupportedException();
default:
throw new NotSupportedException();
}
}
开发者ID:davidleon,项目名称:MOSA-Project,代码行数:61,代码来源:LongOperandTransformationStage.cs
注:本文中的Mosa.Runtime.CompilerFramework.Operands.RegisterOperand类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论