-
-
Save michaeleisel/46d9d5410be827e195b10bf222ce99af to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// in asm_atoi.S... | |
fbld (%rdi) | |
fstpl -8(%rbp) | |
movq -8(%rbp), %xmm0 | |
// in main.c... | |
int main(int argc, const char * argv[]) { | |
const char *c = "2384"; | |
char b[10] = {0}; | |
for (int i = 0; i < sizeof(c); i++) { | |
int shift = (i & 1) ? 0 : 4; | |
b[i / 2] |= (c[i] - '0') << shift; | |
} | |
double z = asm_atoi(b); | |
printf("%lf\n", z); // should print 2384 | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment