fork download
  1. #include <stdio.h>
  2.  
  3. int main() {
  4. double x, result;
  5. double c2 = 2.0, c3 = 3.0, c4 = 4.0, c5 = 5.0, c1 = 1.0;
  6.  
  7. printf("Введите x: ");
  8. scanf("%lf", &x);
  9.  
  10. if (x < 2) {
  11. asm (
  12. "fldl %1;" // загрузить x
  13. "faddl %2;" // прибавить c5 (x + 5)
  14. "fstpl %0;" // сохранить в result
  15. : "=m"(result)
  16. : "m"(x), "m"(c5)
  17. );
  18. }
  19. else if (x < 9) {
  20. asm (
  21. "fldl %1;" // загрузить x
  22. "fmul %%st(0), %%st(0);" // x * x
  23. "fsubl %2;" // вычесть c3 (x^2 - 3)
  24. "fstpl %0;" // сохранить в result
  25. : "=m"(result)
  26. : "m"(x), "m"(c3)
  27. );
  28. }
  29. else {
  30. asm (
  31. "fldl %1;" // загрузить x
  32. "fmull %2;" // умножить на c4 (4x)
  33. "faddl %3;" // прибавить c1 (4x + 1)
  34. "fstpl %0;" // сохранить в result
  35. : "=m"(result)
  36. : "m"(x), "m"(c4), "m"(c1)
  37. );
  38. }
  39.  
  40. printf("f(x) = %lf\n", result);
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 5324KB
stdin
4
stdout
Введите x: f(x) = 13.000000