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