Move driver code out of the library code

This commit is contained in:
Kiril Kovachev 2025-01-24 18:55:26 +00:00
parent 0d55f5cbf9
commit 5b95604383
4 changed files with 31 additions and 21 deletions

View File

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

View File

@ -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
View File

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

23
lib/strcpy.S Normal file
View 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