Architectural Support: x86_64 (#37)
[lunaix-os.git] / lunaix-os / usr / libc / arch / x86_64 / crt0.S
diff --git a/lunaix-os/usr/libc/arch/x86_64/crt0.S b/lunaix-os/usr/libc/arch/x86_64/crt0.S
new file mode 100644 (file)
index 0000000..25786df
--- /dev/null
@@ -0,0 +1,27 @@
+#define __ASM__
+#include <lunaix/syscallid.h>
+
+.section .data
+    .global environ
+    environ:
+        .long 0
+
+.section .text
+    .global _start
+    _start:      
+        xorq %rbp, %rbp
+        
+        movq %rsp, %rax
+        movq (%rax), %rdi
+        leaq 8(%rax), %rsi
+
+        fninit
+        xorq %rax, %rax
+        call main
+        
+    1:
+        movq %rax, %rbx
+        movq $__SYSCALL__exit, %rax
+        int $33
+
+        ud2 // should not reach
\ No newline at end of file