Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * sincos.c
- *
- * Demo für sincos direkt auf einer x86 FPU,
- *
- * clang sincos.c
- *
- * ./a.out
- * -0.756802 -0.653644
- *
- */
- #include <stdio.h>
- int main(){
- static double y asm("fpuy") =0.0; // Sinus
- static double x asm("fpux") =0.0; // Kosinus
- static double a asm("fpua") =0.0; // Winkel
- scanf ("%lf", &a); // Winkel einlesen
- asm ("fldl (fpua)\n\t" // Winkel auf den Register-Stack der FPU
- "fsincos\n\t" // sin und cos mit einem Befehl in der FPU erzeugen
- "fstpl (fpux)\n\t" // Kosinus aus der FPU in die Variable schreiben
- "fstpl (fpuy)"); // Sinus aus der FPU in die Variable schreiben
- printf ("sincos(%.17lf) -> sin: %.17lf cos: %.17lf\n", a, y, x); // alles ausgeben
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement