ARM assembly language

Thread Starter

udin senid

Joined Sep 17, 2013
1
guys im new to this stuff, and this is really confusing me



.section .rodata
label1:
.asciz "Hello World"
.text
.global main

main:

sub sp, sp, #4
str lr, [sp, #0]

ldr r0, = label1
bl puts

ldr lr, [sp, #0]
add sp, sp, #4

mov r0, #0
mov pc, lr



why do we have to store 'lr'??????
why cant we load the string directly to the register and print it?????????
 

Papabravo

Joined Feb 24, 2006
21,225
lr is the link register and the syntax for the operations is:
destination, source.

mov pc,lr is the return instruction from main. It does this by putting the contents of lr into the pc (program counter)

puts is the subroutine that prints the string!!
 

embpic

Joined May 29, 2013
189
yes he is right lr is link register when execution flow goto any function then pc loaded with next instruction and stack pointer loaded with data or register and link register is loaded with RETURN ADDRESS that is where to come after completing that function.
 
Top