Why does the following ARM code set R0 to 0 after the SWI?
.equ SWI_CheckButton, 0x203
.global _start
.text
_start:
mov R0, #1
swi SWI_CheckButton
I’m trying to right a program that takes the form
FunctionA:
swi SWI_CheckButton
cmp R0, #1
beq label1
cmp R0, #2
beq lablel2
...
cmp R0, #9
beq label9
label1:
...
label9:
@do work
bal FunctionA
This gets messed up in label9 because I want it to remember the last key that was pressed but swi SWI_CheckButton resets R0 to 0 (I guess if nothing is pressed).
The problem is swi 0x203 resets R0 to 0 so where would I find a swi that does the same thing but doesn’t reset R0?
I eventually found an example for that SWI. Do a search for
SWI_CheckBlue. What happens is the code of the key being pressed is returned by the SWI routine in R0. If R0 is zero on return, it means no key was being pressed at the time the SWI was called.You probably need to loop round until it comes out non zero.