Last active
August 29, 2015 14:12
-
-
Save xavery/233e2543747abf1b5d10 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
static int sadd(int a, int b) | |
{ | |
asm ( | |
"addl %1, %0\n\t" | |
"jo 1f\n\t" | |
"jmp 4f\n\t" | |
"1: js 2f\n\t" | |
"jmp 3f\n\t" | |
"2: movl $0x7fffffff, %0\n\t" | |
"jmp 4f\n\t" | |
"3: movl $~0, %0\n\t" | |
"4:" | |
: "=r"(a) | |
: "r"(b), "0"(a) | |
: "flags" | |
); | |
return a; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment