1 .text 2 .syntax unified 3 .global memcpy 4 .func memcpy 5 .thumb_func 6 7memcpy: 8 /* on entry 9 * r0 = targ 10 * r1 = src 11 * r2 = len (bytes) 12 * on exit 13 * r0 = targ (unchanged) 14 */ 15 push {r0, r4, lr} 16 17 /* If targ or src are unaligned, drop to byte 18 * processing. */ 19 mov r3, r0 20 movs r4, #3 21 orrs r3, r1 22 ands r3, r4 23 bne L_bytewise 24 25 /* Process words */ 26L_wordwise: 27 cmp r2, #4 28 blo L_bytewise 29 ldr r4, [r1] 30 adds r1, #4 31 str r4, [r0] 32 adds r0, #4 33 subs r2, #4 34 b L_wordwise 35 36 /* Process bytes */ 37L_bytewise: 38 cmp r2, #0 39 beq L_fin 40 ldrb r4, [r1] 41 adds r1, #1 42 strb r4, [r0] 43 adds r0, #1 44 subs r2, #1 45 b L_bytewise 46 47L_fin: 48 pop {r0, r4, pc} 49 .endfunc 50