aboutsummaryrefslogtreecommitdiff
path: root/std
diff options
context:
space:
mode:
authorAndrew Kelley <superjoe30@gmail.com>2015-12-10 15:34:38 -0700
committerAndrew Kelley <superjoe30@gmail.com>2015-12-10 15:34:38 -0700
commit0dbee2300ed28c18ecccaf71f10f68eb2da71266 (patch)
treeac804032eccb2f07258b45023739b694ee937d8c /std
parent3e8a98fa619516d0617a827a79601264a554d88b (diff)
downloadzig-0dbee2300ed28c18ecccaf71f10f68eb2da71266.tar.gz
zig-0dbee2300ed28c18ecccaf71f10f68eb2da71266.zip
add inline assembly support
Diffstat (limited to 'std')
-rw-r--r--std/bootstrap.zig16
1 files changed, 16 insertions, 0 deletions
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
+}