InstEmitException.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. using ARMeilleure.Decoders;
  2. using ARMeilleure.Translation;
  3. using System;
  4. using static ARMeilleure.Instructions.InstEmitFlowHelper;
  5. using static ARMeilleure.IntermediateRepresentation.OperandHelper;
  6. namespace ARMeilleure.Instructions
  7. {
  8. static partial class InstEmit
  9. {
  10. public static void Brk(ArmEmitterContext context)
  11. {
  12. EmitExceptionCall(context, NativeInterface.Break);
  13. }
  14. public static void Svc(ArmEmitterContext context)
  15. {
  16. EmitExceptionCall(context, NativeInterface.SupervisorCall);
  17. }
  18. private static void EmitExceptionCall(ArmEmitterContext context, _Void_U64_S32 func)
  19. {
  20. OpCodeException op = (OpCodeException)context.CurrOp;
  21. context.StoreToContext();
  22. context.Call(func, Const(op.Address), Const(op.Id));
  23. context.LoadFromContext();
  24. if (context.CurrBlock.Next == null)
  25. {
  26. EmitTailContinue(context, Const(op.Address + 4));
  27. }
  28. }
  29. public static void Und(ArmEmitterContext context)
  30. {
  31. OpCode op = context.CurrOp;
  32. Delegate dlg = new _Void_U64_S32(NativeInterface.Undefined);
  33. context.StoreToContext();
  34. context.Call(dlg, Const(op.Address), Const(op.RawOpCode));
  35. context.LoadFromContext();
  36. if (context.CurrBlock.Next == null)
  37. {
  38. EmitTailContinue(context, Const(op.Address + 4));
  39. }
  40. }
  41. }
  42. }