Compare commits

..

No commits in common. "749874138887fc42e0eb9b98498ba76c35b68466" and "0d55f5cbf933edc8751c33209d7f4b53fde6b13f" have entirely different histories.

5 changed files with 21 additions and 28 deletions

3
.gitignore vendored
View File

@ -1,3 +0,0 @@
*.o
a.out
build

View File

@ -1,4 +1,8 @@
.include "lib/alloca.S" .intel_syntax noprefix
.macro alloca size
sub rsp, \size
.endm
.text .text

View File

@ -1,5 +0,0 @@
.intel_syntax noprefix
.macro alloca size
sub rsp, \size
.endm

View File

@ -1,17 +0,0 @@
.intel_syntax noprefix
.text
# 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:
movb r10b, [rdi]
cmpb r10b, 0
je .end
movb [rsi], r10b
inc rdi
inc rsi
jmp strcpy
.end:
ret

View File

@ -1,5 +1,3 @@
.include "lib/strcpy.S"
.intel_syntax noprefix .intel_syntax noprefix
.globl _start .globl _start
@ -7,6 +5,22 @@
.text .text
# String-copying routine.
# Commented-out lines would also return the starting address of the destination address.
strcpy:
# push rsi
.loop:
movb r10b, [rdi]
cmpb r10b, 0
je .end
movb [rsi], r10b
inc rdi
inc rsi
jmp .loop
.end:
# pop rax
ret
_start: _start:
mov rdi, offset str2 mov rdi, offset str2