...
This commit is contained in:
12
src/CLI/Runtime/entry.s
Normal file
12
src/CLI/Runtime/entry.s
Normal file
@@ -0,0 +1,12 @@
|
||||
.intel_syntax noprefix
|
||||
.extern main
|
||||
.section .text
|
||||
|
||||
.global _start
|
||||
_start:
|
||||
mov rdi, rsp
|
||||
# func main(args: []^string): i64
|
||||
call main
|
||||
mov rdi, rax
|
||||
mov rax, 60
|
||||
syscall
|
||||
20
src/CLI/Runtime/nub_memcpy.s
Normal file
20
src/CLI/Runtime/nub_memcpy.s
Normal file
@@ -0,0 +1,20 @@
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
|
||||
# func nub_memcpy(destination: ^u8, source: ^u8, count: u64): ^u8
|
||||
.global nub_memcpy
|
||||
nub_memcpy:
|
||||
push rdi
|
||||
mov rcx, rdx
|
||||
test rcx, rcx
|
||||
jz memcpy_done
|
||||
memcpy_loop:
|
||||
mov al, BYTE PTR [rsi]
|
||||
mov BYTE PTR [rdi], al
|
||||
inc rsi
|
||||
inc rdi
|
||||
dec rcx
|
||||
jnz memcpy_loop
|
||||
memcpy_done:
|
||||
pop rax
|
||||
ret
|
||||
19
src/CLI/Runtime/nub_memset.s
Normal file
19
src/CLI/Runtime/nub_memset.s
Normal file
@@ -0,0 +1,19 @@
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
|
||||
# func nub_memset(destination: ^u8, value: i8, count: u64): ^u8
|
||||
.global nub_memset
|
||||
nub_memset:
|
||||
push rdi
|
||||
mov rcx, rdx
|
||||
mov al, sil
|
||||
test rcx, rcx
|
||||
jz memset_done
|
||||
memset_loop:
|
||||
mov BYTE PTR [rdi], al
|
||||
inc rdi
|
||||
dec rcx
|
||||
jnz memset_loop
|
||||
memset_done:
|
||||
pop rax
|
||||
ret
|
||||
14
src/CLI/Runtime/nub_panic.s
Normal file
14
src/CLI/Runtime/nub_panic.s
Normal file
@@ -0,0 +1,14 @@
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
|
||||
# func nub_panic(message: ^u8, message_length: u64): void
|
||||
.global nub_panic
|
||||
nub_panic:
|
||||
mov rdx, rsi
|
||||
mov rsi, rdi
|
||||
mov rax, 1
|
||||
mov rdi, 2
|
||||
syscall
|
||||
mov rax, 60
|
||||
mov rdi, 101
|
||||
syscall
|
||||
22
src/CLI/Runtime/nub_strcmp.s
Normal file
22
src/CLI/Runtime/nub_strcmp.s
Normal file
@@ -0,0 +1,22 @@
|
||||
.intel_syntax noprefix
|
||||
.section .text
|
||||
|
||||
# func nub_strcmp(lhs: ^u8, rhs: ^u8): bool
|
||||
.global nub_strcmp
|
||||
nub_strcmp:
|
||||
xor rdx, rdx
|
||||
strcmp_loop:
|
||||
mov al, BYTE PTR [rsi + rdx]
|
||||
mov bl, BYTE PTR [rdi + rdx]
|
||||
inc rdx
|
||||
cmp al, bl
|
||||
jne strcmp_not_equal
|
||||
cmp al, 0
|
||||
je strcmp_equal
|
||||
jmp strcmp_loop
|
||||
strcmp_not_equal:
|
||||
mov rax, 0
|
||||
ret
|
||||
strcmp_equal:
|
||||
mov rax, 1
|
||||
ret
|
||||
Reference in New Issue
Block a user