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
|
.intel_syntax noprefix
|
||||||
|
|
||||||
.globl _start
|
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
||||||
|
# String-copying routine. Strings should be null-terminated.
|
||||||
# String-copying routine.
|
# Input: rdi = source string base, rsi = destination string base
|
||||||
# Commented-out lines would also return the starting address of the destination address.
|
# No check is done for buffer overflow.
|
||||||
strcpy:
|
strcpy:
|
||||||
# push rsi
|
|
||||||
.loop:
|
|
||||||
movb r10b, [rdi]
|
movb r10b, [rdi]
|
||||||
cmpb r10b, 0
|
cmpb r10b, 0
|
||||||
je .end
|
je .end
|
||||||
movb [rsi], r10b
|
movb [rsi], r10b
|
||||||
inc rdi
|
inc rdi
|
||||||
inc rsi
|
inc rsi
|
||||||
jmp .loop
|
jmp strcpy
|
||||||
.end:
|
.end:
|
||||||
# pop rax
|
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user