Created
November 28, 2016 18:50
-
-
Save patshaughnessy/3fd6f5b9a6dc66a3e9cf4024bd927286 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Prepare a new stack frame (save the old base pointer, and set | |
the new base pointer to the current stack pointer) | |
pushq %rbp | |
movq %rsp, %rbp | |
# Get the address of your string (lea = load effective address) | |
# and put it into the rdi register as a parameter to printf. | |
leaq L_.str(%rip), %rdi | |
# Not sure why this is needed - I believe it sets eax to zero. | |
# must be another parameter to printf? | |
xorl %eax, %eax | |
callq _printf | |
# Same thing here - set eax to zero, which is now the | |
# return value of the function. | |
xorl %eax, %eax | |
# Restore the old stack frame and return to the caller | |
popq %rbp | |
retq | |
# And this is the string literal that is passed to printf. | |
L_.str: ## @.str | |
.asciz "Hello World!\n" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment