tbs0309.pp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. { This code was first written by Florian
  2. to test the GDB output for FPU
  3. he thought first that FPU output was wrong
  4. but in fact it is a bug in FPC :( }
  5. program bug0309;
  6. var
  7. a,b : double;
  8. _as,bs : single;
  9. al,bl : extended;
  10. aw,bw : integer;
  11. ai,bi : longint;
  12. ac : comp;
  13. begin
  14. {$ifdef CPU86}
  15. {$asmmode att}
  16. asm
  17. fninit;
  18. end;
  19. a:=1;
  20. b:=2;
  21. asm
  22. movl $1,%eax
  23. fldl a
  24. fldl b
  25. faddp %st,%st(1)
  26. fstpl a
  27. end;
  28. { the above generates wrong code in binary writer
  29. fldl is replaced by flds !!
  30. if using -alt option to force assembler output
  31. all works correctly PM }
  32. writeln('a = ',a,' should be 3');
  33. if a<>3.0 then
  34. Halt(1);
  35. a:=1.0;
  36. a:=a+b;
  37. writeln('a = ',a,' should be 3');
  38. _as:=0;
  39. al:=0;
  40. asm
  41. fldl a
  42. fsts _as
  43. fstpt al
  44. end;
  45. if (_as<>3.0) or (al<>3.0) then
  46. Halt(1);
  47. ai:=5;
  48. bi:=5;
  49. asm
  50. fildl ai
  51. fstpl a
  52. end;
  53. if a<>5.0 then
  54. Halt(1);
  55. ac:=5;
  56. asm
  57. fildl ai
  58. fstpl a
  59. end;
  60. if a<>5.0 then
  61. Halt(1);
  62. aw:=-4;
  63. bw:=45;
  64. asm
  65. fildw aw
  66. fstpl a
  67. end;
  68. if a<>-4.0 then
  69. Halt(1);
  70. ac:=345;
  71. asm
  72. fildq ac
  73. fstpl a
  74. end;
  75. if a<>345.0 then
  76. Halt(1);
  77. {$endif CPU86}
  78. end.