mirror of
https://github.com/Mathewnd/Astral.git
synced 2026-10-30 14:08:21 +00:00
kernel: user safe strlen
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
objects := $(patsubst %.c,%.o,$(wildcard *.c)) israsm.o context.o syscall.o sched.o
|
||||
objects := $(patsubst %.c,%.o,$(wildcard *.c)) israsm.o context.o syscall.o sched.o ustringasm.o
|
||||
subdirs=boot
|
||||
OBJPATH=$(OBJDIR)/arch/${TARGET}/
|
||||
export
|
||||
@@ -27,3 +27,8 @@ sched.o: sched.asm
|
||||
nasm -f elf64 -o $@ $<
|
||||
mkdir -p $(OBJPATH)
|
||||
cp $@ $(OBJPATH)/$@
|
||||
|
||||
ustringasm.o: ustring.asm
|
||||
nasm -f elf64 -o $@ $<
|
||||
mkdir -p $(OBJPATH)
|
||||
cp $@ $(OBJPATH)/$@
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
section .text:
|
||||
|
||||
global arch_u_strlen
|
||||
global arch_u_strlen_cont
|
||||
|
||||
arch_u_strlen:
|
||||
xor rcx, rcx
|
||||
.loop:
|
||||
cmp byte [rdi],0
|
||||
je .done
|
||||
inc rcx
|
||||
inc rdi
|
||||
.done:
|
||||
mov [rsi], rcx
|
||||
xor rax, rax
|
||||
ret
|
||||
arch_u_strlen_cont:
|
||||
mov rax, 1
|
||||
ret
|
||||
Reference in New Issue
Block a user