Category:ARM Assembly: Difference between revisions

m
Added info about the link register
m (→‎Setting Flags: Formatting fix)
m (Added info about the link register)
Line 63:
 
Most processors would have to push and pop the condition code register between the compare and the branch. Otherwise, the act of loading <code>r2</code> and <code>r3</code> would affect the outcome of the branch. Not so on the ARM!
 
===Call Stack===
Most processors, including the x86 family, will use the same hardware stack for function arguments, local variables, and return addresses. The ARM doesn't actually need to store a return address onto the stack until subroutines are nested (though ARM Assembly written by a compiler will most likely do so anyway.) This is because the <i>link register</i> or <code>r13</code> is responsible for holding the return address. <code>BL</code> is the equivalent of <code>CALL</code> on the x86 architecture, and instead of pushing the program counter to the stack, it gets copied to the link register before the branch. Once the function is complete, execution returns by moving the value in the link register back into the program counter. For nested subroutines, the link register will need to be pushed onto the stack, as the link register can only "remember" the return address of the most recent <code>BL</code> instruction.
 
===Limitations of the ARM===
1,489

edits