mirror of
https://github.com/creeperlv/SVM.git
synced 2026-01-11 04:49:53 +00:00
Added Invoke support.
This commit is contained in:
@@ -27,6 +27,7 @@ namespace SVM.Core
|
|||||||
public static uint InitGPMemorySize = 696320;
|
public static uint InitGPMemorySize = 696320;
|
||||||
public Object? AdditionalData = null;
|
public Object? AdditionalData = null;
|
||||||
public ErrorIDs ErrorIDs = new ErrorIDs();
|
public ErrorIDs ErrorIDs = new ErrorIDs();
|
||||||
|
public DebugSymbol? symbols;
|
||||||
public void Init(uint StackSize = 1024 * 1024, uint RegisterSize = 512, uint GPMemory = uint.MaxValue)
|
public void Init(uint StackSize = 1024 * 1024, uint RegisterSize = 512, uint GPMemory = uint.MaxValue)
|
||||||
{
|
{
|
||||||
registers.Init(RegisterSize);
|
registers.Init(RegisterSize);
|
||||||
@@ -51,9 +52,31 @@ namespace SVM.Core
|
|||||||
block.Init(GPMemory);
|
block.Init(GPMemory);
|
||||||
SetMemory(1, block);
|
SetMemory(1, block);
|
||||||
registers.SetData<SVMPointer>((int)CFOffset, new SVMPointer() { index = 1, offset = 0 });
|
registers.SetData<SVMPointer>((int)CFOffset, new SVMPointer() { index = 1, offset = 0 });
|
||||||
|
|
||||||
|
var cfPtr = GetPointer(ReadCallFrameRegisterAsPtr());
|
||||||
|
cfPtr.SetData(ulong.MaxValue - 4);
|
||||||
registers.SetData<SVMPointer>((int)SPOffset, new SVMPointer() { index = 1, offset = StackSize });
|
registers.SetData<SVMPointer>((int)SPOffset, new SVMPointer() { index = 1, offset = StackSize });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
public void Invoke(ulong PC)
|
||||||
|
{
|
||||||
|
while (true)
|
||||||
|
{
|
||||||
|
var ptr = ReadCallFrameRegisterAsPtr();
|
||||||
|
if (ptr.offset == 0) return;
|
||||||
|
Step();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public void Invoke(string funcName)
|
||||||
|
{
|
||||||
|
if (symbols != null)
|
||||||
|
{
|
||||||
|
if (symbols.Functions.TryGetValue(funcName, out var func))
|
||||||
|
{
|
||||||
|
Invoke(func);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
public bool isReachBinaryEnd()
|
public bool isReachBinaryEnd()
|
||||||
{
|
{
|
||||||
uint PCOffset = 1;
|
uint PCOffset = 1;
|
||||||
@@ -233,6 +256,7 @@ namespace SVM.Core
|
|||||||
var cfPtr = GetPointer(ReadCallFrameRegisterAsPtr());
|
var cfPtr = GetPointer(ReadCallFrameRegisterAsPtr());
|
||||||
PC = cfPtr.GetData<ulong>();
|
PC = cfPtr.GetData<ulong>();
|
||||||
PC -= 1;
|
PC -= 1;
|
||||||
|
WriteCallFrameRegister(ReadCallFrameRegister() - 1);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PrimaryInstruction.System:
|
case PrimaryInstruction.System:
|
||||||
|
|||||||
Reference in New Issue
Block a user