I'm playing around a bit with keypresses and wanted to put something together with it. It's a very simple idea: detect a keypress, branch to the appropriate label, do your thing and branch back to the keypress detection loop. In my attempt below the ctrl key exits the program and the enter key branches to another part. My problem is that this branch stays, when it goes back to the keypress detection loop (at least I think it does), it keeps branching to the part where the enter key points to. Have I misunderstood something about ARM or am I doing something wrong codewise?
#include <os.h>
main: .global main
push {r4-r11, lr}
bl lcd_ingray
bl clrscr
ldr r1, =0x900E0010
keycheck:
ldrh r2, [r1, #0]
tst r2, #1 << 1
bne enterkey
ldrh r2, [r1, #14]
tst r2, #1 << 9
bne ctrlkey
b keycheck
@ handle various keypresses
enterkey:
b stuff
ctrlkey:
b end
stuff:
b keycheck
end:
mov r0, #0
pop {r4-r11, pc}