commit d519ef5fab85e6532e94055f513fb7a8247517eb
parent 89bbd49c16d6f6cff682163057f7abb1338193ed
Author: Matsuda Kenji <info@mtkn.jp>
Date: Mon, 18 Mar 2024 12:03:10 +0900
hard fault
Diffstat:
2 files changed, 8 insertions(+), 21 deletions(-)
diff --git a/ex3/main.c b/ex3/main.c
@@ -53,7 +53,7 @@ main(void) {
p0.id = 0;
p0.r[13] = 0x20000100; // sp
- p0.r[14] = (unsigned int) 0xdeadbeef; // lr
+ p0.r[14] = (unsigned int) main; // lr
p0.r[15] = 0x20000001; // pc
p0.next = &p1;
@@ -63,9 +63,9 @@ main(void) {
p1.r[15] = 0x20000101; // pc
p1.next = NULL;
- restore_context(ptab.head->r);
-
+ //proc0();
for (;;) {
+ puts("a");
wfi();
for (int i = 0; i < 17; i++) {
printh(ptab.head->r[i]);
diff --git a/ex3/proc.s b/ex3/proc.s
@@ -1,24 +1,9 @@
+ .align 1
.section .proc0, "a"
.global proc0
proc0:
-// ldr r0, msg0
-// bl puts
-
- mov r0, sp
- bl printh
- mov r0, #'\n'
- bl putbyte
- mov r0, pc
- bl printh
- mov r0, #'\n'
- bl putbyte
- mrs r0, xpsr
- bl printh
- mov r0, #'\n'
- bl putbyte
- bl putbyte
-
- wfi
+ ldr r0, msg0
+ bl puts
b proc0
.align 2
@@ -38,6 +23,7 @@ proc1:
msg1:
.asciz "proc1"
+ .align 1
.global print_sp
print_sp:
mov r4, lr
@@ -134,6 +120,7 @@ isr_alarm:
alarm_msg:
.asciz "alarm"
+ .align 1
// void restore_context(unsigned int r[17]);
// This function does not return, and needs not to save any registers.
// How to restore all of the registers?