Subroutines Flashcards
instruction used to call subroutines
BL subroutineName
what does BL stand for
branch and link
what does BL do
it remembers the address of the instruction immediatelt following the branch and link
it acts as a normal branch instruction
within subroutine, how to branch back to main/where you were before
BX LR
at the beginning of a subroutine, you should always push….
LR and any registers used by the subroutine
at the end of a subroutine, you should always pop
PC and any registers used by the subroutine
why do we push an pop any registers used as local variables within the subroutine
to hide the fact that they were used within the subroutine
what should be included in interface specification commments
- name of subroutine
- description of subroutine
- what parameters will be passed
- what it returns
what does AAPCS stand for
ARM architecture procedure call standards
according to AAPCS what registers should be used for passing parameters in subroutines
R0-R3
according to AAPCS what registers should be used for local variables in subroutines
R4-R12
in what register is the link register
r14
in what register is the program counter
r15
when popping at the end of the subroutine, why do we pop right into the PC
itll go right to that address after the pop instruction
through what registers should values be returned
r0