InstEmitException.cs 1.4 KB

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