commit 16068031ffd513bc9388c2059150bdc17c87ec23
parent 62de635eef84f10d862e88771739a678f9c8de71
Author: Matsuda Kenji <info@mtkn.jp>
Date: Thu, 28 Mar 2024 09:48:08 +0900
update xpsr
Diffstat:
2 files changed, 13 insertions(+), 11 deletions(-)
diff --git a/ex3/main.c b/ex3/main.c
@@ -54,15 +54,15 @@ main(void) {
p0.id = 0;
p0.r[13] = 0x20000100; // sp
p0.r[14] = (unsigned int) halt; // lr
- p0.r[15] = (unsigned int) proc0 + 1; // pc
- p0.r[16] = 0;
+ p0.r[15] = (unsigned int) proc0; // pc
+ p0.r[16] = 0x01000000; // EPSR's thumb bit
p0.next = &p1;
p1.id = 1;
p1.r[13] = 0x20000200; // sp
p1.r[14] = (unsigned int) halt; // lr
- p1.r[15] = (unsigned int) proc1 + 1; // pc
- p1.r[16] = 0;
+ p1.r[15] = (unsigned int) proc1; // pc
+ p1.r[16] = 0x01000000; // EPSR's thumb bit
p1.next = NULL;
set_psp();
diff --git a/ex3/proc.s b/ex3/proc.s
@@ -4,8 +4,12 @@
proc0:
ldr r0, =msg0
bl puts
- ldr r0, =0xdeadbeef
+ mov r0, #0
+ mov r1, #1
+ cmp r0, r1
+ sub sp, #4
wfi
+ add sp, #4
b proc0
.align 2
@@ -123,20 +127,18 @@ isr_alarm:
ldr r1, [r0, #(12 * 4)] // r12
str r1, [r2, #0x10]
ldr r1, [r0, #(13 * 4)] // psp
- //msr psp, r1 // hard fault
+ msr psp, r1 // hard fault
ldr r1, [r0, #(14 * 4)] // lr
str r1, [r2, #0x14]
ldr r1, [r0, #(15 * 4)] // ReturnAddress
str r1, [r2, #0x18]
-// ldr r1, [r0, #(16 * 4)] // xpsr
-// str r1, [r2, #0x1c]
+ ldr r1, [r0, #(16 * 4)] // xpsr
+ str r1, [r2, #0x1c]
ldr r0, =(1000 * 1000)
bl set_alarm
- pop {r5}
-
- bx r5
+ pop {pc}
.align 2
alarm_msg: