Created
May 22, 2018 20:24
-
-
Save qguv/5ed37cf43e0555174b2c54edbfa22a91 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
/* Input a number and watch it get clobbered by another! */ | |
#include <stdio.h> | |
#include <stdlib.h> | |
#define answer(__op1) __asm__ ( \ | |
"movl $42, %0\n\t" \ | |
: "=r" (__op1) \ | |
: "0" (__op1) \ | |
); | |
int main(int argc, char *argv[]) | |
{ | |
if (argc != 2) { | |
fputs("Usage: asm_test NUMBER\n", stderr); | |
exit(EXIT_FAILURE); | |
} | |
int x = strtol(argv[1], NULL, 10); | |
answer(x); | |
printf("%d\n", x); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment