summaryrefslogtreecommitdiff
path: root/PGU/CHAP8/helloworld-lib.s
diff options
context:
space:
mode:
Diffstat (limited to 'PGU/CHAP8/helloworld-lib.s')
-rw-r--r--PGU/CHAP8/helloworld-lib.s20
1 files changed, 20 insertions, 0 deletions
diff --git a/PGU/CHAP8/helloworld-lib.s b/PGU/CHAP8/helloworld-lib.s
new file mode 100644
index 0000000..6e04968
--- /dev/null
+++ b/PGU/CHAP8/helloworld-lib.s
@@ -0,0 +1,20 @@
+# Hello world using DSOs
+
+.section .data
+ helloworld:
+ .ascii "hello world\n\0"
+
+.section .text
+
+.globl _start
+
+_start:
+
+ # This differs from the book. In x86_64, arguments are passed through
+ # registers most of the time, in contrast with i386, where we can push
+ # them in the stack.
+ movq $helloworld, %rdi
+ call printf
+
+ movq $50, %rdi
+ call exit