.text .global main @****************************************************************** .equ NUL, 0 @ NUL is used for end of string strcopy: @ Entry to "strcopy" function @ R0 = address of destination string @ R1 = address of source string l1: ldrb r2,[r1],#1 @ Load byte into R2 and update R1 strb r2,[r0],#1 @ Store the byte and update R0 cmp r2,#NUL @ Check for NUL terminator bne l1 @ Repeat loop if not bx lr @******************************************************************* main: push {lr} ldr r0,=str_before @ Print str_before to the console bl puts ldr r0,=srcstr bl puts ldr r0, =dststr bl puts ldr r0,=dststr @ R0 := address of destination string ldr r1,=srcstr @ R1 := address of source string bl strcopy @ Call the function "strcopy" (in "copy.s") ldr r0,=str_after @ Print str_after to the console bl puts @ then print the two strings (again) ldr r0,=srcstr bl puts ldr r0, =dststr bl puts pop {pc} .data @ Read/write data follows .align @ Align to a 32-bit boundary srcstr: .asciz "First (source) string" dststr: .asciz "Second (destination) string" str_before: .asciz "Before copying:" @ Note: NOT ".asciz"! str_after: .asciz "After copying:" @ The same, using C-style escapes .end