AInstEmitException.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. using ChocolArm64.Decoder;
  2. using ChocolArm64.State;
  3. using ChocolArm64.Translation;
  4. using System;
  5. namespace ChocolArm64.Instruction
  6. {
  7. static partial class AInstEmit
  8. {
  9. public static void Brk(AILEmitterCtx Context)
  10. {
  11. EmitExceptionCall(Context, nameof(ARegisters.OnBreak));
  12. }
  13. public static void Svc(AILEmitterCtx Context)
  14. {
  15. EmitExceptionCall(Context, nameof(ARegisters.OnSvcCall));
  16. }
  17. private static void EmitExceptionCall(AILEmitterCtx Context, string MthdName)
  18. {
  19. AOpCodeException Op = (AOpCodeException)Context.CurrOp;
  20. Context.EmitStoreState();
  21. Context.EmitLdarg(ATranslatedSub.RegistersArgIdx);
  22. Context.EmitLdc_I4(Op.Id);
  23. Context.EmitCall(typeof(ARegisters), MthdName);
  24. if (Context.CurrBlock.Next != null)
  25. {
  26. Context.EmitLoadState(Context.CurrBlock.Next);
  27. }
  28. }
  29. public static void Und(AILEmitterCtx Context)
  30. {
  31. throw new NotImplementedException($"Undefined instruction at {Context.CurrOp.Position:x16}");
  32. }
  33. }
  34. }