diff --git a/alloca.S b/driver/alloca_driver.S similarity index 91% rename from alloca.S rename to driver/alloca_driver.S index 7ad9b56..432709c 100644 --- a/alloca.S +++ b/driver/alloca_driver.S @@ -1,8 +1,4 @@ -.intel_syntax noprefix - -.macro alloca size -sub rsp, \size -.endm +.include "lib/alloca.S" .text diff --git a/strcpy.S b/driver/strcpy_driver.S similarity index 59% rename from strcpy.S rename to driver/strcpy_driver.S index 2796c29..37de014 100644 --- a/strcpy.S +++ b/driver/strcpy_driver.S @@ -1,3 +1,5 @@ + .include "lib/strcpy.S" + .intel_syntax noprefix .globl _start @@ -5,22 +7,6 @@ .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 diff --git a/lib/alloca.S b/lib/alloca.S new file mode 100644 index 0000000..707c4f0 --- /dev/null +++ b/lib/alloca.S @@ -0,0 +1,5 @@ +.intel_syntax noprefix + +.macro alloca size +sub rsp, \size +.endm diff --git a/lib/strcpy.S b/lib/strcpy.S new file mode 100644 index 0000000..147e2eb --- /dev/null +++ b/lib/strcpy.S @@ -0,0 +1,23 @@ + .intel_syntax noprefix + + .globl _start + + .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 +