@@ -990,7 +990,7 @@ void __attribute__((noinline)) serial_dump_and_reset(dump_crash_reason reason)
// sample SP/PC
sp = SP;
- GETPC(&pc);
+ pc = GETPC();
// extend WDT long enough to allow writing the entire stream
wdt_enable(WDTO_8S);
@@ -1,24 +1,21 @@
#pragma once
#include <stdint.h>
+#include "macros.h"
#ifdef __AVR_ATmega2560__
// return the current PC (on AVRs with 22bit PC)
-static inline void GETPC(uint32_t* v)
+FORCE_INLINE __uint24 GETPC(void)
{
- uint8_t a, b, c;
- asm
- (
+ __uint24 ret;
+ asm (
"rcall .\n"
- "pop %2\n"
- "pop %1\n"
- "pop %0\n"
- : "=r" (a), "=r" (b), "=r" (c)
+ "pop %A0\n"
+ "pop %B0\n"
+ "pop %C0\n"
+ : "=&r" (ret)
);
- ((uint8_t*)v)[0] = a;
- ((uint8_t*)v)[1] = b;
- ((uint8_t*)v)[2] = c;
- ((uint8_t*)v)[3] = 0;
+ return ret;
}
#endif
@@ -59,7 +59,7 @@ static void __attribute__((noinline)) xfdump_dump_core(dump_header_t& hdr, uint3
hdr.sp = SP;
- GETPC(&hdr.pc);
+ hdr.pc = GETPC();
// write header
static_assert(sizeof(hdr) <= 256, "header is larger than a single page write");