mirror of
https://github.com/danbulant/Cosmos
synced 2026-05-20 04:48:53 +00:00
42 lines
No EOL
1.2 KiB
C#
42 lines
No EOL
1.2 KiB
C#
using System;
|
|
using Mono.Cecil.Cil;
|
|
using CPUx86 = Indy.IL2CPU.Assembler.X86;
|
|
|
|
namespace Indy.IL2CPU.IL.X86 {
|
|
[OpCode(Code.Stobj)]
|
|
public class Stobj: Op {
|
|
public Stobj(Mono.Cecil.Cil.Instruction aInstruction, MethodInformation aMethodInfo)
|
|
: base(aInstruction, aMethodInfo) {
|
|
}
|
|
public override void DoAssemble() {
|
|
//new CPUx86.Pop(CPUx86.Registers.EDX);
|
|
//new CPUx86.Pop(CPUx86.Registers.EAX);
|
|
//new CPUx86.Move(CPUx86.Registers.AtEAX, CPUx86.Registers.EDX);
|
|
int xFieldSize = Assembler.StackSizes.Pop();
|
|
Assembler.StackSizes.Pop();
|
|
new CPUx86.Move("ecx", "[esp + " + xFieldSize + "]");
|
|
for (int i = 0; i < (xFieldSize / 4); i++) {
|
|
new CPUx86.Pop("eax");
|
|
new CPUx86.Move("dword [ecx + 0x" + (xFieldSize - ((i + 1) * 4)).ToString("X") + "]", "eax");
|
|
}
|
|
switch (xFieldSize % 4) {
|
|
case 1: {
|
|
new CPUx86.Pop("eax");
|
|
new CPUx86.Move("byte [ecx]", "al");
|
|
break;
|
|
}
|
|
case 2: {
|
|
new CPUx86.Pop("eax");
|
|
new CPUx86.Move("word [ecx]", "ax");
|
|
break;
|
|
}
|
|
case 0: {
|
|
break;
|
|
}
|
|
default:
|
|
throw new Exception("Remainder size " + (xFieldSize % 4) + " not supported!");
|
|
}
|
|
new CPUx86.Add("esp", "4");
|
|
}
|
|
}
|
|
} |