From a4822b7946cc9641f7f33d5df4a0d940a1b8c93c Mon Sep 17 00:00:00 2001
From: gdkchan <gab.dark.100@gmail.com>
Date: Fri, 9 Nov 2018 16:41:20 -0200
Subject: [PATCH] Fix BLR when the source reg is X30 (#493)

---
 ChocolArm64/Instructions/InstEmitFlow.cs | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ChocolArm64/Instructions/InstEmitFlow.cs b/ChocolArm64/Instructions/InstEmitFlow.cs
index 7d0897cd6f..0e9f7cb017 100644
--- a/ChocolArm64/Instructions/InstEmitFlow.cs
+++ b/ChocolArm64/Instructions/InstEmitFlow.cs
@@ -72,11 +72,14 @@ namespace ChocolArm64.Instructions
         {
             OpCodeBReg64 op = (OpCodeBReg64)context.CurrOp;
 
+            context.EmitLdintzr(op.Rn);
+            context.EmitSttmp();
+
             context.EmitLdc_I(op.Position + 4);
             context.EmitStint(CpuThreadState.LrIndex);
             context.EmitStoreState();
-            context.EmitLdintzr(op.Rn);
 
+            context.EmitLdtmp();
             context.Emit(OpCodes.Ret);
         }