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
#include <cinttypes> | |
uint64_t div(uint64_t u1, uint64_t u0, uint64_t v) { | |
uint64_t result; | |
uint64_t remainder; | |
__asm__("divq %[v]" : "=a"(result), "=d"(remainder) : [v] "r"(v), "a"(u0), "d"(u1)); | |
return result; | |
} | |
int main() { | |
div(1, 0, 1); // 2**64 / 1 | |
} | |
/* | |
g++ -std=c++17 -O0 main.cpp -o main | |
./main | |
“./main” terminated by signal SIGFPE (Floating point exception) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment