45 lines
656 B
NASM
45 lines
656 B
NASM
;
|
|
; Written by the Chair for Operating Systems, RWTH Aachen University
|
|
;
|
|
; NO Copyright (C) 2010-2012, Stefan Lankes
|
|
; consider these trivial functions to be public domain.
|
|
;
|
|
; These functions are distributed on an "AS IS" BASIS,
|
|
; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
;
|
|
|
|
[BITS 64]
|
|
SECTION .text
|
|
global strcpy
|
|
strcpy:
|
|
push rdi
|
|
|
|
L1:
|
|
lodsb
|
|
stosb
|
|
test al, al
|
|
jne L1
|
|
|
|
pop rax
|
|
ret
|
|
|
|
global strncpy
|
|
strncpy:
|
|
push rdi
|
|
mov rcx, rdx
|
|
|
|
L2:
|
|
dec rcx
|
|
js L3
|
|
lodsb
|
|
stosb
|
|
test al, al
|
|
jne L1
|
|
rep
|
|
stosb
|
|
|
|
L3:
|
|
pop rax
|
|
ret
|
|
|
|
SECTION .note.GNU-stack noalloc noexec nowrite progbits
|