aboutsummaryrefslogtreecommitdiff
path: root/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs
diff options
context:
space:
mode:
authorTSR Berry <20988865+TSRBerry@users.noreply.github.com>2023-04-08 01:22:00 +0200
committerMary <thog@protonmail.com>2023-04-27 23:51:14 +0200
commitcee712105850ac3385cd0091a923438167433f9f (patch)
tree4a5274b21d8b7f938c0d0ce18736d3f2993b11b1 /src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs
parentcd124bda587ef09668a971fa1cac1c3f0cfc9f21 (diff)
Move solution and projects to src
Diffstat (limited to 'src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs')
-rw-r--r--src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs
new file mode 100644
index 00000000..2264e9d1
--- /dev/null
+++ b/src/Ryujinx.HLE/HOS/Tamper/CodeEmitters/SaveOrRestoreRegisterWithMask.cs
@@ -0,0 +1,33 @@
+namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters
+{
+ /// <summary>
+ /// Code type 0xC2 performs saving or restoring of multiple registers using a bitmask.
+ /// NOTE: Registers are saved and restored to a different set of registers than the ones used
+ /// for the other opcodes (Save Registers).
+ /// </summary>
+ class SaveOrRestoreRegisterWithMask
+ {
+ private const int OperationTypeIndex = 2;
+ private const int RegisterMaskIndex = 4;
+
+ private const int RegisterMaskSize = 4;
+
+ public static void Emit(byte[] instruction, CompilationContext context)
+ {
+ // C2x0XXXX
+ // x: Operand Type, see below.
+ // X: 16-bit bitmask, bit i == save or restore register i.
+
+ byte operationType = instruction[OperationTypeIndex];
+ ulong mask = InstructionHelper.GetImmediate(instruction, RegisterMaskIndex, RegisterMaskSize);
+
+ for (byte regIndex = 0; mask != 0; mask >>= 1, regIndex++)
+ {
+ if ((mask & 0x1) != 0)
+ {
+ SaveOrRestoreRegister.Impl(operationType, regIndex, regIndex, context);
+ }
+ }
+ }
+ }
+}