LoadRegisterWithConstant.cs 954 B

12345678910111213141516171819202122232425262728
  1. using Ryujinx.HLE.HOS.Tamper.Operations;
  2. namespace Ryujinx.HLE.HOS.Tamper.CodeEmitters
  3. {
  4. /// <summary>
  5. /// Code type 4 allows setting a register to a constant value.
  6. /// </summary>
  7. class LoadRegisterWithConstant
  8. {
  9. const int RegisterIndex = 3;
  10. const int ValueImmediateIndex = 8;
  11. const int ValueImmediateSize = 16;
  12. public static void Emit(byte[] instruction, CompilationContext context)
  13. {
  14. // 400R0000 VVVVVVVV VVVVVVVV
  15. // R: Register to use.
  16. // V: Value to load.
  17. Register destinationRegister = context.GetRegister(instruction[RegisterIndex]);
  18. ulong immediate = InstructionHelper.GetImmediate(instruction, ValueImmediateIndex, ValueImmediateSize);
  19. Value<ulong> sourceValue = new Value<ulong>(immediate);
  20. context.CurrentOperations.Add(new OpMov<ulong>(destinationRegister, sourceValue));
  21. }
  22. }
  23. }