aboutsummaryrefslogtreecommitdiff
path: root/prologue.asm
diff options
context:
space:
mode:
Diffstat (limited to 'prologue.asm')
-rw-r--r--prologue.asm134
1 files changed, 0 insertions, 134 deletions
diff --git a/prologue.asm b/prologue.asm
deleted file mode 100644
index 74d9de3..0000000
--- a/prologue.asm
+++ /dev/null
@@ -1,134 +0,0 @@
-; SYS_EXIT equ 0x2000001 ;code
-; SYS_FORK equ 0x2000002 ;--
-; SYS_READ equ 0x2000003 ;fd, buf, len
-; SYS_WRITE equ 0x2000004 ;fd, buf, len
-
-global start
-default rel
-
-section .text
-start:
- call main
- mov rdi, rax
- mov eax, 0x2000001
- syscall
- jmp $
-
-putc:
- push rax
- push rdi
- push rsi
- push rdx
- push rcx
- push r11
- mov eax, 0x2000004
- mov edi, 1
- lea rsi, [rsp+56]
- mov edx, edi
- syscall
- pop r11
- pop rcx
- pop rdx
- pop rsi
- pop rdi
- pop rax
- ret
-
-putint:
- push rdi
- push rsi
- push rax
- push rbx
- push rcx
- push rdx
- push r11
- mov rax, [rsp+64]
- mov ebx, 18
- test rax, rax
- jz .numzero
-
- mov ecx, 10
-
-.strlp:
- xor edx, edx
- div rcx
- add dl, '0'
- dec rbx
- mov [rsp+rbx], dl
- test rax, rax
- jnz .strlp
- jmp .strdone
-
-.numzero:
- dec rbx
- mov byte [rsp+rbx], '0'
- jmp .strdone
-
-.strdone:
- mov eax, 0x2000004
- mov edi, 1
- lea rsi, [rsp+rbx]
- mov edx, 18
- sub rdx, rbx
- syscall
-
- pop r11
- pop rdx
- pop rcx
- pop rbx
- pop rax
- pop rsi
- pop rdi
- ret
-
-getc:
- push rdi
- push rsi
- push rdx
- push rcx
- push r11
- mov eax, 0x2000003
- xor edi, edi
- mov rsi, rsp
- mov edx, 1
- syscall
- cmp rax, 1
- jne .fail
- mov rax, [rsp]
-.finish:
- pop r11
- pop rcx
- pop rdx
- pop rsi
- pop rdi
- ret
-.fail:
- mov rax, -1
- jmp .finish
-
-_builtin_malloc:
- push rdi
- push rsi
- push rdx
- push r8
- push r9
- push r10
- push r11
- push rcx
- xor edi, edi
- mov rsi, [rsp+72]
- mov edx, 0x03
- mov r10d, 0x1001
- mov r8d, -1
- xor r9d, r9d
- mov eax, 0x20000C5
- syscall
- pop rcx
- pop r11
- pop r10
- pop r9
- pop r8
- pop rdx
- pop rsi
- pop rdi
- ret