tb0267.pp 1.4 KB

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