2018-02-04 23:08:20 +00:00
|
|
|
using ChocolArm64.Decoder;
|
|
|
|
using ChocolArm64.State;
|
|
|
|
using ChocolArm64.Translation;
|
2018-02-12 03:37:20 +00:00
|
|
|
using System.Reflection;
|
2018-02-04 23:08:20 +00:00
|
|
|
|
|
|
|
namespace ChocolArm64.Instruction
|
|
|
|
{
|
|
|
|
static partial class AInstEmit
|
|
|
|
{
|
2018-02-12 03:37:20 +00:00
|
|
|
private const BindingFlags Binding = BindingFlags.NonPublic | BindingFlags.Instance;
|
|
|
|
|
2018-02-10 13:24:16 +00:00
|
|
|
public static void Brk(AILEmitterCtx Context)
|
|
|
|
{
|
|
|
|
EmitExceptionCall(Context, nameof(ARegisters.OnBreak));
|
|
|
|
}
|
|
|
|
|
2018-02-04 23:08:20 +00:00
|
|
|
public static void Svc(AILEmitterCtx Context)
|
2018-02-10 13:24:16 +00:00
|
|
|
{
|
|
|
|
EmitExceptionCall(Context, nameof(ARegisters.OnSvcCall));
|
|
|
|
}
|
|
|
|
|
|
|
|
private static void EmitExceptionCall(AILEmitterCtx Context, string MthdName)
|
2018-02-04 23:08:20 +00:00
|
|
|
{
|
|
|
|
AOpCodeException Op = (AOpCodeException)Context.CurrOp;
|
|
|
|
|
|
|
|
Context.EmitStoreState();
|
|
|
|
|
|
|
|
Context.EmitLdarg(ATranslatedSub.RegistersArgIdx);
|
|
|
|
|
|
|
|
Context.EmitLdc_I4(Op.Id);
|
|
|
|
|
2018-02-12 03:37:20 +00:00
|
|
|
MethodInfo MthdInfo = typeof(ARegisters).GetMethod(MthdName, Binding);
|
|
|
|
|
|
|
|
Context.EmitCall(MthdInfo);
|
2018-02-04 23:08:20 +00:00
|
|
|
|
|
|
|
if (Context.CurrBlock.Next != null)
|
|
|
|
{
|
|
|
|
Context.EmitLoadState(Context.CurrBlock.Next);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void Und(AILEmitterCtx Context)
|
|
|
|
{
|
2018-02-10 17:20:46 +00:00
|
|
|
AOpCode Op = Context.CurrOp;
|
|
|
|
|
|
|
|
Context.EmitStoreState();
|
|
|
|
|
|
|
|
Context.EmitLdarg(ATranslatedSub.RegistersArgIdx);
|
|
|
|
|
|
|
|
Context.EmitLdc_I8(Op.Position);
|
|
|
|
Context.EmitLdc_I4(Op.RawOpCode);
|
|
|
|
|
2018-02-12 03:37:20 +00:00
|
|
|
string MthdName = nameof(ARegisters.OnUndefined);
|
|
|
|
|
|
|
|
MethodInfo MthdInfo = typeof(ARegisters).GetMethod(MthdName, Binding);
|
|
|
|
|
|
|
|
Context.EmitCall(MthdInfo);
|
2018-02-10 17:20:46 +00:00
|
|
|
|
|
|
|
if (Context.CurrBlock.Next != null)
|
|
|
|
{
|
|
|
|
Context.EmitLoadState(Context.CurrBlock.Next);
|
|
|
|
}
|
2018-02-04 23:08:20 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|