rp2040

RP2040 Programming without SDK
Log | Files | Refs

commit 3ae2e8a223fecd39b899e61c9ba6be0d6f9b5534
parent a33c6373643c843aa5cf61081cfc32ab296eae8e
Author: Matsuda Kenji <info@mtkn.jp>
Date:   Wed, 28 Feb 2024 08:50:17 +0900

add a function

Diffstat:
Mex3/main.s | 25++++++++++++++++++-------
1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/ex3/main.s b/ex3/main.s @@ -136,12 +136,8 @@ unreset_chk1: bl set_alarm loop: - ldr r0, =0xdeadcafe - bl printh - mov r0, #'\r' - bl putbyte - mov r0, #'\n' - bl putbyte + ldr r0, =message + bl puts wfi b loop @@ -229,6 +225,20 @@ alpha: bge printh_loop pop {r4, r5, r6, r7, pc} + // puts prints null terminated string starting at r0. +puts: + push {r4, lr} + mov r4, r0 +puts_loop: + ldrb r0, [r4, #0] + cmp r0, #0 + beq puts_end + bl putbyte + add r4, #1 + b puts_loop +puts_end: + pop {r4, pc} + putbyte: ldr r3, uart0_base mov r1, #1 @@ -341,4 +351,5 @@ sio_base: .word 0xd0000000 ppb_base: .word 0xe0000000 - +message: + .asciz "Hello, World!\r\n"