1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
diff --git a/firmware/target/arm/system-arm.c b/firmware/target/arm/system-arm.c
index 01d2ba6..5b47fe5 100644
--- a/firmware/target/arm/system-arm.c
+++ b/firmware/target/arm/system-arm.c
@@ -86,6 +86,17 @@ void __attribute__((noreturn)) UIE(unsigned int pc, unsigned int num)
     }   /* num == 1 || num == 2 // prefetch/data abort */
 #endif /* !defined(CPU_ARM7TDMI */

+    int lr;
+    asm volatile(
+        "mrs r0, cpsr   \n" /* save current mode */
+        "mrs r1, spsr   \n" /* load spsr */
+        "msr cpsr_c, r1 \n"
+        "mov %0, lr     \n" /* read lr from spsr */
+        "msr cpsr_c, r0 \n"
+        : "=r"(lr) : : "r0", "r1"
+    );
+    lcd_putsf(0, line++, "LR: 0x%8x", lr);
+
     lcd_update();

     disable_interrupt(IRQ_FIQ_STATUS);