InstEmitException.cs 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using ARMeilleure.Decoders;
  2. using ARMeilleure.Translation;
  3. using static ARMeilleure.Instructions.InstEmitFlowHelper;
  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, nameof(NativeInterface.Break));
  12. }
  13. public static void Svc(ArmEmitterContext context)
  14. {
  15. EmitExceptionCall(context, nameof(NativeInterface.SupervisorCall));
  16. }
  17. private static void EmitExceptionCall(ArmEmitterContext context, string name)
  18. {
  19. OpCodeException op = (OpCodeException)context.CurrOp;
  20. context.StoreToContext();
  21. context.Call(typeof(NativeInterface).GetMethod(name), Const(op.Address), Const(op.Id));
  22. context.LoadFromContext();
  23. }
  24. public static void Und(ArmEmitterContext context)
  25. {
  26. OpCode op = context.CurrOp;
  27. string name = nameof(NativeInterface.Undefined);
  28. context.StoreToContext();
  29. context.Call(typeof(NativeInterface).GetMethod(name), Const(op.Address), Const(op.RawOpCode));
  30. context.LoadFromContext();
  31. }
  32. }
  33. }