tfpu1.pp 2.5 KB

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