using System; using CPUx86 = Cosmos.IL2CPU.X86; namespace Cosmos.IL2CPU.X86.IL { [Cosmos.IL2CPU.OpCode(ILOpCode.Code.Mul)] public class Mul : ILOp { public Mul(Cosmos.IL2CPU.Assembler aAsmblr) : base(aAsmblr) { } public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) { var xStackContent = Assembler.Stack.Pop(); if (xStackContent.Size > 4) { if (xStackContent.IsFloat) { new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.XMM0, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 8 }; new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.XMM1, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true }; new CPUx86.SSE.MulSS { SourceReg = CPUx86.Registers.XMM0, DestinationReg = CPUx86.Registers.XMM1}; new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.XMM1, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 8 }; new CPUx86.Push { DestinationValue = 0 }; new CPUx86.Sub { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, SourceReg = CPUx86.Registers.XMM0 }; } else { new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; new CPUx86.Multiply { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, Size = 32 }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 8 }; new CPUx86.Push { DestinationValue = 0 }; new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; } } else { if (xStackContent.IsFloat) { new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.XMM0, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.XMM1, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true }; new CPUx86.SSE.MulSS { DestinationReg = CPUx86.Registers.XMM1, SourceReg = CPUx86.Registers.XMM0 }; new CPUx86.SSE.MoveSS { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, SourceReg = CPUx86.Registers.XMM1 }; } else { new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; new CPUx86.Multiply { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, Size = 32 }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ESP, SourceValue = 4 }; new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; } } } // using System; // using System.IO; // // // using CPU = Cosmos.IL2CPU.X86; // // namespace Cosmos.IL2CPU.IL.X86 { // [OpCode(OpCodeEnum.Mul)] // public class Mul: Op { // private string mNextLabel; // private string mCurLabel; // private uint mCurOffset; // private MethodInformation mMethodInformation; // public Mul(ILReader aReader, MethodInformation aMethodInfo) // : base(aReader, aMethodInfo) { // mMethodInformation = aMethodInfo; // mCurOffset = aReader.Position; // mCurLabel = IL.Op.GetInstructionLabel(aReader); // mNextLabel = IL.Op.GetInstructionLabel(aReader.NextPosition); // } // public override void DoAssemble() { // Multiply(Assembler, GetServiceProvider(), // mCurLabel, mMethodInformation, mCurOffset, mNextLabel); // } // } // } } }