rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit 462ecf4d7dae62b165ea69ec90df8ceaf6f95568
parent b6befe55d289bcee8a73e339af2e0a4093de7aee
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Sat, 24 Feb 2024 12:08:13 +0900

add svcall handler

Diffstat:
Mex3/main.s | 53+++++++++++++++++++++++++++++++----------------------
1 file changed, 31 insertions(+), 22 deletions(-)

diff --git a/ex3/main.s b/ex3/main.s @@ -105,37 +105,46 @@ wait_vco: lsl r0, #14 str r0, [r3, #0] // SYSCFG: PROC0_NMI_MASK - bl int_systick - - ldr r4, ppb_base - ldr r5, =0xe018 + ldr r1, =0x20000000 + mov r0, #0 + str r0, [r1, #0] loop: - ldr r0, ='\r' - bl putbyte - ldr r0, [r4, r5] // M0PLUS: SYST_CVR - bl printh - ldr r0, ='\n' - bl putbyte - ldr r0, ='\r' - bl putbyte - mov r0, sp - bl printh - ldr r0, ='\n' - bl putbyte wfi + svc #0 b loop // functions +int_svcall: + push {lr} + mov r0, #'\r' + bl putbyte + mov r0, #'s' + bl putbyte + mov r0, #'v' + bl putbyte + mov r0, #'c' + bl putbyte + mov r0, #'a' + bl putbyte + mov r0, #'l' + bl putbyte + mov r0, #'l' + bl putbyte + mov r0, #'\n' + bl putbyte + pop {pc} + int_systick: push {lr} - ldr r0, ='\r' + mov r0, #'\r' bl putbyte - ldr r3, ppb_base - ldr r1, =0xe010 - ldr r0, [r3, r1] // SYSCFG: PROC0_NMI_MASK + ldr r1, =0x20000000 + ldr r0, [r1, #0] + add r0, #1 + str r0, [r1, #0] bl printh - ldr r0, ='\n' + mov r0, #'\n' bl putbyte pop {pc} @@ -285,7 +294,7 @@ vectors: .word (reset+1) // 8 .word (reset+1) // 9 .word (reset+1) // 10 - .word (reset+1) // 11 + .word (int_svcall+1) // 11 svcall .word (reset+1) // 12 .word (reset+1) // 13 .word (reset+1) // 14