test_svc.cpp 866 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. /* This file is part of the dynarmic project.
  2. * Copyright (c) 2022 MerryMage
  3. * SPDX-License-Identifier: 0BSD
  4. */
  5. #include <optional>
  6. #include <catch2/catch_test_macros.hpp>
  7. #include "./testenv.h"
  8. using namespace Dynarmic;
  9. class ArmSvcTestEnv : public ArmTestEnv {
  10. public:
  11. std::optional<u32> svc_called = std::nullopt;
  12. void CallSVC(u32 swi) override {
  13. svc_called = swi;
  14. }
  15. };
  16. TEST_CASE("arm: svc", "[arm][A32]") {
  17. ArmSvcTestEnv test_env;
  18. A32::Jit jit{A32::UserConfig{&test_env}};
  19. test_env.code_mem = {
  20. 0xef0001ee, // svc #0x1ee
  21. 0xe30a0071, // mov r0, #41073
  22. 0xeafffffe, // b +#0
  23. };
  24. jit.SetCpsr(0x000001d0); // User-mode
  25. test_env.ticks_left = 3;
  26. jit.Run();
  27. REQUIRE(test_env.svc_called == 0x1ee);
  28. REQUIRE(jit.Regs()[15] == 0x00000008);
  29. REQUIRE(jit.Regs()[0] == 41073);
  30. }