testfpu.pp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. program test_fp_instructions;
  2. function test : extended;
  3. var
  4. x,y : integer;
  5. statusword,controlword : word;
  6. z,t : longint;
  7. a,b,c : comp;
  8. begin
  9. x:=5;
  10. c:=5;
  11. t:=5;
  12. z:=4;
  13. a:=20;
  14. { test all FPU instructions using 's' and 'l' suffix
  15. for word and dword size PM }
  16. {$asmmode att}
  17. asm
  18. fildl z
  19. fiadds x
  20. fistpq b
  21. fildl z
  22. ficoms x
  23. fistpq b
  24. fildl z
  25. ficomps x
  26. fildl z
  27. fidivs x
  28. fistpq b
  29. fildl z
  30. fidivrs x
  31. fistpq b
  32. fildl z
  33. fisubs x
  34. fistpq b
  35. fildl z
  36. fisubrs x
  37. fistpq b
  38. fildl z
  39. fimuls x
  40. fistpq b
  41. end;
  42. if a<>b then
  43. begin
  44. Writeln('Error in FPU att syntax code generation');
  45. Halt(1);
  46. end;
  47. asm
  48. fildl z
  49. fiaddl t
  50. fistpq b
  51. fildl z
  52. ficoml t
  53. fistpq b
  54. fildl z
  55. ficompl t
  56. fildl z
  57. fidivl t
  58. fistpq b
  59. fildl z
  60. fidivrl t
  61. fistpq b
  62. fildl z
  63. fisubl t
  64. fistpq b
  65. fildl z
  66. fisubrl t
  67. fistpq b
  68. fildl z
  69. fimull t
  70. fistpq b
  71. end;
  72. if a<>b then
  73. begin
  74. Writeln('Error in FPU att syntax code generation');
  75. Halt(1);
  76. end;
  77. { test CW and SW instructions }
  78. { FSTSW FNSTSW
  79. FLDCW FSTCW FNSTCW }
  80. asm
  81. fstsw statusword
  82. fstsww statusword
  83. fnstsw statusword
  84. fnstsww statusword
  85. fstcw controlword
  86. fstcww controlword
  87. fnstcw controlword
  88. fnstcww controlword
  89. fldcw controlword
  90. fldcww controlword
  91. end;
  92. {$asmmode intel}
  93. asm
  94. fild dword ptr z
  95. fimul dword ptr t
  96. fistp qword ptr b
  97. fild dword ptr z
  98. fimul word ptr x
  99. fistp qword ptr b
  100. end;
  101. if a<>b then
  102. begin
  103. Writeln('Error in FPU code generation');
  104. Halt(1);
  105. end;
  106. { test CW and SW instructions }
  107. asm
  108. fstsw word ptr [statusword]
  109. fnstsw word ptr [statusword]
  110. fstcw word ptr [controlword]
  111. fnstcw word ptr[controlword]
  112. fldcw word ptr [controlword]
  113. end;
  114. test:=b;
  115. end;
  116. var
  117. z : extended;
  118. begin
  119. z:=test;
  120. end.