Compare commits
No commits in common. "749874138887fc42e0eb9b98498ba76c35b68466" and "0d55f5cbf933edc8751c33209d7f4b53fde6b13f" have entirely different histories.
7498741388
...
0d55f5cbf9
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +0,0 @@
|
||||
*.o
|
||||
a.out
|
||||
build
|
@ -1,4 +1,8 @@
|
||||
.include "lib/alloca.S"
|
||||
.intel_syntax noprefix
|
||||
|
||||
.macro alloca size
|
||||
sub rsp, \size
|
||||
.endm
|
||||
|
||||
.text
|
||||
|
@ -1,5 +0,0 @@
|
||||
.intel_syntax noprefix
|
||||
|
||||
.macro alloca size
|
||||
sub rsp, \size
|
||||
.endm
|
17
lib/strcpy.S
17
lib/strcpy.S
@ -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
|
@ -1,5 +1,3 @@
|
||||
.include "lib/strcpy.S"
|
||||
|
||||
.intel_syntax noprefix
|
||||
|
||||
.globl _start
|
||||
@ -7,6 +5,22 @@
|
||||
.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:
|
||||
|
||||
mov rdi, offset str2
|
Loading…
Reference in New Issue
Block a user