From 0dbee2300ed28c18ecccaf71f10f68eb2da71266 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 10 Dec 2015 15:34:38 -0700 Subject: add inline assembly support --- std/bootstrap.zig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 std/bootstrap.zig (limited to 'std/bootstrap.zig') diff --git a/std/bootstrap.zig b/std/bootstrap.zig new file mode 100644 index 0000000000..348b74a27e --- /dev/null +++ b/std/bootstrap.zig @@ -0,0 +1,16 @@ + +// TODO conditionally compile this differently for non-ELF +#attribute("naked") +export fn _start() -> unreachable { + // TODO conditionally compile this differently for other architectures and other OSes + asm volatile (" + mov (%%rsp), %%rdi // first parameter is argc + lea 0x8(%%rsp), %%rsi // second parameter is argv + lea 0x10(%%rsp,%%rdi,8), %%rdx // third paremeter is env + callq main + mov %%rax, %%rdi // return value is the parameter to exit syscall + mov $60, %%rax // 60 is exit syscall number + syscall + "); + unreachable +} -- cgit v1.2.3