CpuTestAluRs32.cs 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #define AluRs32
  2. using NUnit.Framework;
  3. namespace Ryujinx.Tests.Cpu
  4. {
  5. [Category("AluRs32")]
  6. public sealed class CpuTestAluRs32 : CpuTest32
  7. {
  8. #if AluRs32
  9. #region "ValueSource (Opcodes)"
  10. private static uint[] _Add_Adds_Rsb_Rsbs_()
  11. {
  12. return new[]
  13. {
  14. 0xe0800000u, // ADD R0, R0, R0, LSL #0
  15. 0xe0900000u, // ADDS R0, R0, R0, LSL #0
  16. 0xe0600000u, // RSB R0, R0, R0, LSL #0
  17. 0xe0700000u // RSBS R0, R0, R0, LSL #0
  18. };
  19. }
  20. private static uint[] _Adc_Adcs_Rsc_Rscs_Sbc_Sbcs_()
  21. {
  22. return new[]
  23. {
  24. 0xe0a00000u, // ADC R0, R0, R0
  25. 0xe0b00000u, // ADCS R0, R0, R0
  26. 0xe0e00000u, // RSC R0, R0, R0
  27. 0xe0f00000u, // RSCS R0, R0, R0
  28. 0xe0c00000u, // SBC R0, R0, R0
  29. 0xe0d00000u // SBCS R0, R0, R0
  30. };
  31. }
  32. #endregion
  33. [Test, Pairwise]
  34. public void Adc_Adcs_Rsc_Rscs_Sbc_Sbcs([ValueSource("_Adc_Adcs_Rsc_Rscs_Sbc_Sbcs_")] uint opcode,
  35. [Values(0u, 13u)] uint rd,
  36. [Values(1u, 13u)] uint rn,
  37. [Values(2u, 13u)] uint rm,
  38. [Values(0x00000000u, 0x7FFFFFFFu,
  39. 0x80000000u, 0xFFFFFFFFu)] uint wn,
  40. [Values(0x00000000u, 0x7FFFFFFFu,
  41. 0x80000000u, 0xFFFFFFFFu)] uint wm,
  42. [Values] bool carryIn)
  43. {
  44. opcode |= ((rm & 15) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12);
  45. uint sp = TestContext.CurrentContext.Random.NextUInt();
  46. SingleOpcode(opcode, r1: wn, r2: wm, sp: sp, carry: carryIn);
  47. CompareAgainstUnicorn();
  48. }
  49. [Test, Pairwise]
  50. public void Add_Adds_Rsb_Rsbs([ValueSource("_Add_Adds_Rsb_Rsbs_")] uint opcode,
  51. [Values(0u, 13u)] uint rd,
  52. [Values(1u, 13u)] uint rn,
  53. [Values(2u, 13u)] uint rm,
  54. [Values(0x00000000u, 0x7FFFFFFFu,
  55. 0x80000000u, 0xFFFFFFFFu)] uint wn,
  56. [Values(0x00000000u, 0x7FFFFFFFu,
  57. 0x80000000u, 0xFFFFFFFFu)] uint wm,
  58. [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // <LSL, LSR, ASR, ROR>
  59. [Values(0u, 15u, 16u, 31u)] uint amount)
  60. {
  61. opcode |= ((rm & 15) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12);
  62. opcode |= ((shift & 3) << 5) | ((amount & 31) << 7);
  63. uint sp = TestContext.CurrentContext.Random.NextUInt();
  64. SingleOpcode(opcode, r1: wn, r2: wm, sp: sp);
  65. CompareAgainstUnicorn();
  66. }
  67. #endif
  68. }
  69. }