Polish up strcpy code
This commit is contained in:
parent
d23173c8de
commit
7498741388
14
lib/strcpy.S
14
lib/strcpy.S
@ -1,23 +1,17 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl _start
|
||||
|
||||
.text
|
||||
|
||||
|
||||
# String-copying routine.
|
||||
# Commented-out lines would also return the starting address of the destination address.
|
||||
# String-copying routine. Strings should be null-terminated.
|
||||
# Input: rdi = source string base, rsi = destination string base
|
||||
# No check is done for buffer overflow.
|
||||
strcpy:
|
||||
# push rsi
|
||||
.loop:
|
||||
movb r10b, [rdi]
|
||||
cmpb r10b, 0
|
||||
je .end
|
||||
movb [rsi], r10b
|
||||
inc rdi
|
||||
inc rsi
|
||||
jmp .loop
|
||||
jmp strcpy
|
||||
.end:
|
||||
# pop rax
|
||||
ret
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user