CpuTestAluRs32.cs 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  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 uint[]
  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 uint[]
  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. private const int RndCnt = 2;
  34. private const int RndCntAmount = 2;
  35. [Test, Pairwise]
  36. public void Adc_Adcs_Rsc_Rscs_Sbc_Sbcs([ValueSource("_Adc_Adcs_Rsc_Rscs_Sbc_Sbcs_")] uint opcode,
  37. [Values(0u, 13u)] uint rd,
  38. [Values(1u, 13u)] uint rn,
  39. [Values(2u, 13u)] uint rm,
  40. [Values(0x00000000u, 0x7FFFFFFFu,
  41. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn,
  42. [Values(0x00000000u, 0x7FFFFFFFu,
  43. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wm,
  44. [Values] bool carryIn)
  45. {
  46. opcode |= ((rm & 15) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12);
  47. uint sp = TestContext.CurrentContext.Random.NextUInt();
  48. SingleOpcode(opcode, r1: wn, r2: wm, sp: sp, carry: carryIn);
  49. CompareAgainstUnicorn();
  50. }
  51. [Test, Pairwise]
  52. public void Add_Adds_Rsb_Rsbs([ValueSource("_Add_Adds_Rsb_Rsbs_")] uint opcode,
  53. [Values(0u, 13u)] uint rd,
  54. [Values(1u, 13u)] uint rn,
  55. [Values(2u, 13u)] uint rm,
  56. [Values(0x00000000u, 0x7FFFFFFFu,
  57. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wn,
  58. [Values(0x00000000u, 0x7FFFFFFFu,
  59. 0x80000000u, 0xFFFFFFFFu)] [Random(RndCnt)] uint wm,
  60. [Values(0b00u, 0b01u, 0b10u, 0b11u)] uint shift, // <LSL, LSR, ASR, ROR>
  61. [Values(0u, 15u, 16u, 31u)] [Random(0u, 31u, RndCntAmount)] uint amount)
  62. {
  63. opcode |= ((rm & 15) << 0) | ((rn & 15) << 16) | ((rd & 15) << 12);
  64. opcode |= ((shift & 3) << 5) | ((amount & 31) << 7);
  65. uint sp = TestContext.CurrentContext.Random.NextUInt();
  66. SingleOpcode(opcode, r1: wn, r2: wm, sp: sp);
  67. CompareAgainstUnicorn();
  68. }
  69. #endif
  70. }
  71. }