commit a41034b590794a16c2852ec2cd7bb04c51ec5869
parent f9584892ede82f88c87a567f79f8e11fed42cdfa
Author: Matsuda Kenji <info@mtkn.jp>
Date: Wed, 27 Mar 2024 07:54:19 +0900
restore psp
Diffstat:
2 files changed, 5 insertions(+), 8 deletions(-)
diff --git a/ex3/main.c b/ex3/main.c
@@ -52,14 +52,14 @@ main(void) {
ptab.tail = &p1;
p0.id = 0;
- p0.r[13] = 0x20000100; // sp
+ p0.r[13] = 0x200000e0; // sp
p0.r[14] = (unsigned int) halt; // lr
p0.r[15] = (unsigned int) proc0 + 1; // pc
p0.r[16] = 0;
p0.next = &p1;
p1.id = 1;
- p1.r[13] = 0x20000200; // sp
+ p1.r[13] = 0x200000e0; // sp
p1.r[14] = (unsigned int) halt; // lr
p1.r[15] = (unsigned int) proc1 + 1; // pc
p1.r[16] = 0;
diff --git a/ex3/proc.s b/ex3/proc.s
@@ -89,7 +89,7 @@ isr_alarm:
str r0, [r1, r3] // r12
add r3, r3, #4
- mov r0, sp
+ mrs r0, psp
str r0, [r1, r3] // sp ???
add r2, r2, #4
@@ -121,6 +121,8 @@ isr_alarm:
str r1, [r2, #0xc]
ldr r1, [r0, #(12 * 4)] // r12
str r1, [r2, #0x10]
+ ldr r1, [r0, #(13 * 4)] // psp
+ msr psp, r1
ldr r1, [r0, #(14 * 4)] // lr
str r1, [r2, #0x14]
ldr r1, [r0, #(15 * 4)] // ReturnAddress
@@ -128,16 +130,11 @@ isr_alarm:
// ldr r1, [r0, #(16 * 4)] // xpsr
// str r1, [r2, #0x1c]
- mov r4, r0
-
ldr r0, =(1000 * 1000)
bl set_alarm
pop {r5}
-// ldr r0, [r4, #(13 * 4)] // sp
-// mov sp, r0
-
bx r5
.align 2