tb0267.pp 1.3 KB

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