With a background in programming, I find I am still having a tough time with assembly language concepts. All tutorials online that I have found so far are somewhat helpful but I find myself jumping from tutorial to tutorial to piece things together. Anyway I have several conceptual questions regarding the following ARM assembly program and appreciate any help and pointers.
@converts a lowercase letter to an uppercase letter
.global _start
_start:
MOV R7, #3
MOV R0, #0
MOV R2, #1
LDR R1, =character
SWI 0
_uppercase:
LDR R1, =character
LDR R0, [R1]
BIC R0, R0, #32
STR R0, [R1]
_write:
MOV R7, #4
MOV R0, #1
MOV R2, #1
SWI 0
end:
MOV R7, #1
SWI 0
.data
character:
.ascii " "
- I understand what system calls are, such as read from keyboard or output to screen, but what determines what register is in charge of what system calls and how do I know what values need to be passed to those registers?
- In the example, register R0 is used for a syscall in line 6 to take input from the keyboard and then used again in line 13 to load register R1 address into itself. What happens to the original value/syscall from line 6? Is each line executed line by line during runtime? Where is the information stored that I am going to take input from the keyboard (line 6)?
- Similar to question 2, I am storing the address of a word to register R0 in line 15, but making a system call in line 19 to output to memory using the same register. What happened to the memory address that was stored in register R0 from line 15?
- Why does each label section have to have an SWI 0? Why does the _uppercase section not have an SWI 0?
- Why does the termination of the program require a syscall (line 24) before SWI 0?
Thanks in advance for answers and I hope this post can help others understand some ARM concepts.