InstEmitException.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. using ARMeilleure.Decoders;
  2. using ARMeilleure.Translation;
  3. using static ARMeilleure.IntermediateRepresentation.Operand.Factory;
  4. namespace ARMeilleure.Instructions
  5. {
  6. static partial class InstEmit
  7. {
  8. public static void Brk(ArmEmitterContext context)
  9. {
  10. EmitExceptionCall(context, nameof(NativeInterface.Break));
  11. }
  12. public static void Svc(ArmEmitterContext context)
  13. {
  14. EmitExceptionCall(context, nameof(NativeInterface.SupervisorCall));
  15. }
  16. private static void EmitExceptionCall(ArmEmitterContext context, string name)
  17. {
  18. OpCodeException op = (OpCodeException)context.CurrOp;
  19. context.StoreToContext();
  20. context.Call(typeof(NativeInterface).GetMethod(name), Const(op.Address), Const(op.Id));
  21. context.LoadFromContext();
  22. Translator.EmitSynchronization(context);
  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. }