rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit 7e304f12d94a6d4ea5cc5518f2e093508cb746f4
parent 27af25bb882a8c50c2c7e0290eb6c77a166f9886
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sat, 16 Mar 2024 09:04:33 +0900

rewrite isr_alarm in assembly

Diffstat:
Mex3/main.c | 8+++-----
Mex3/proc.s | 23+++++++++++++++++++++++
Mex3/start.s | 1+
3 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/ex3/main.c b/ex3/main.c @@ -8,7 +8,6 @@ void *get_sp(void); void wfi(void); void *memcpy(void *s1, void *s2, long n); void setreg(void); -void print_sr(void); extern char proc0_start, proc0_size; extern char proc1_start, proc1_size; @@ -52,7 +51,6 @@ main(void) { p1.r[15] = (void *) 0x20000100; // pc for (;;) { - print_sr(); puts(""); setreg(); wfi(); } @@ -82,12 +80,10 @@ void isr_svcall(void) { puts("svcall"); } - +/* void isr_alarm(void) { int *sp = get_sp(); - print_sr(); - puts(""); for (int i = 0; i < 12; i += 1) { printh(sp+i); printh((void *)*(sp+i)); @@ -96,3 +92,4 @@ isr_alarm(void) { scheduler(); set_alarm(1000 * 1000); } +*/ +\ No newline at end of file diff --git a/ex3/proc.s b/ex3/proc.s @@ -51,3 +51,25 @@ print_sr: mrs r0, ipsr bl printh pop {pc} + + .global isr_alarm +isr_alarm: + push {r4, r5, r6, lr} + bl get_sp + mov r4, r0 + mov r5, sp + add r5, #16 + mov r6, r5 + add r6, #32 // 8 words +isr_alarm_loop: + ldr r0, [r5, #0] + bl printh + mov r0, #'\n' + bl putbyte + add r5, r5, #4 + cmp r5, r6 + blt isr_alarm_loop + bl scheduler + ldr r0, =(1000 * 1000) + bl set_alarm + pop {r4, r5, r6, pc} +\ No newline at end of file diff --git a/ex3/start.s b/ex3/start.s @@ -252,6 +252,7 @@ memcpy_loop: // void putbyte(char b); // Putbyte writes b to uart0. + .global putbyte putbyte: ldr r3, uart0_base mov r1, #1