As you can see from my comments, my problem is I don't seem to know how to get the 65 from char into r4.
Code: Select all
@ macros.s @ experimenting with a couple of macros .section .data nl: .byte 0xA @ ascii codes spc: .byte 0x20 char: @ initially holds 65 / 'A'. .byte 0x41 .macro print_ch a @ NB this macro clobbers registers r0, r1, r2 and r7. mov r0, $1 @ A function would be wiser. This is just a demo. ldr r1, =\a mov r2, $1 mov r7, $4 svc $0 .endm .section .text .globl _start _start: ldr r3, =char mov r4, $0x41 @ this is the bit that confuses me. I wanted to load the number 65 from r3 @ but if I do "ldr r4, [r3]" the program just prints a capital 'A' and exits. This immediate load works, @ but it's annoying when I have the number right there in "char". print_ch nl loop: print_ch char print_ch spc cmp r4, $0x5a @ are we done? addlt r4, r4, $1 strlt r4, [r3] @ increment char variable. blt loop print_ch nl mov r7, $1 svc $0 .end
Also, if anyone with assembly code knowledge would mind looking at ths other post, I'd really appreciate it.
Question about number printing function.