From 31f4955afb95dbe35eda20c590eb3bf8d251866d Mon Sep 17 00:00:00 2001 From: David Crocker Date: Wed, 3 Nov 2021 23:48:45 +0000 Subject: Added GetStackPointer function to CoreN2G --- src/Hardware/ExceptionHandlers.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'src/Hardware/ExceptionHandlers.cpp') diff --git a/src/Hardware/ExceptionHandlers.cpp b/src/Hardware/ExceptionHandlers.cpp index 5bb9fdb3..38be6c22 100644 --- a/src/Hardware/ExceptionHandlers.cpp +++ b/src/Hardware/ExceptionHandlers.cpp @@ -89,8 +89,7 @@ [[noreturn]] void OutOfMemoryHandler() noexcept { - register const uint32_t * stack_ptr asm ("sp"); - SoftwareReset(SoftwareResetReason::outOfMemory, stack_ptr); + SoftwareReset(SoftwareResetReason::outOfMemory, GetStackPointer()); } // Exception handlers @@ -284,8 +283,7 @@ namespace std // The default terminate handler pulls in sprintf and lots of other functions, which makes the binary too large. So we replace it. [[noreturn]] void Terminate() noexcept { - register const uint32_t * stack_ptr asm ("sp"); - SoftwareReset(SoftwareResetReason::terminateCalled, stack_ptr); + SoftwareReset(SoftwareResetReason::terminateCalled, GetStackPointer()); } namespace __cxxabiv1 @@ -295,14 +293,12 @@ namespace __cxxabiv1 extern "C" [[noreturn]] void __cxa_pure_virtual() noexcept { - register const uint32_t * stack_ptr asm ("sp"); - SoftwareReset(SoftwareResetReason::pureOrDeletedVirtual, stack_ptr); + SoftwareReset(SoftwareResetReason::pureOrDeletedVirtual, GetStackPointer()); } extern "C" [[noreturn]] void __cxa_deleted_virtual() noexcept { - register const uint32_t * stack_ptr asm ("sp"); - SoftwareReset(SoftwareResetReason::pureOrDeletedVirtual, stack_ptr); + SoftwareReset(SoftwareResetReason::pureOrDeletedVirtual, GetStackPointer()); } // End -- cgit v1.2.3