Move driver code out of the library code
This commit is contained in:
parent
0d55f5cbf9
commit
5b95604383
@ -1,8 +1,4 @@
|
|||||||
.intel_syntax noprefix
|
.include "lib/alloca.S"
|
||||||
|
|
||||||
.macro alloca size
|
|
||||||
sub rsp, \size
|
|
||||||
.endm
|
|
||||||
|
|
||||||
.text
|
.text
|
||||||
|
|
@ -1,3 +1,5 @@
|
|||||||
|
.include "lib/strcpy.S"
|
||||||
|
|
||||||
.intel_syntax noprefix
|
.intel_syntax noprefix
|
||||||
|
|
||||||
.globl _start
|
.globl _start
|
||||||
@ -5,22 +7,6 @@
|
|||||||
.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
|
5
lib/alloca.S
Normal file
5
lib/alloca.S
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
.intel_syntax noprefix
|
||||||
|
|
||||||
|
.macro alloca size
|
||||||
|
sub rsp, \size
|
||||||
|
.endm
|
23
lib/strcpy.S
Normal file
23
lib/strcpy.S
Normal file
@ -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
|
||||||
|
|
Loading…
Reference in New Issue
Block a user