tmmx1.pp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. { %CPU=i386 }
  2. { %maxversion=1.0.99 }
  3. { this contains currently only a basic test of mmx support }
  4. { the following instructions are tested:
  5. PSUBW
  6. PSUBUSW
  7. PADDW
  8. PADDUSW
  9. }
  10. uses
  11. mmx;
  12. procedure do_error(l : longint);
  13. begin
  14. writeln('Error near number ',l);
  15. halt(1);
  16. end;
  17. function equal(const v1,v2 : tmmxword) : boolean;
  18. var
  19. i : integer;
  20. begin
  21. equal:=false;
  22. for i:=0 to 3 do
  23. if v1[i]<>v2[i] then
  24. exit;
  25. equal:=true;
  26. end;
  27. procedure testmmxword;
  28. var t1,t5 : tmmxword;
  29. const
  30. c0 : tmmxword = (0,0,0,0);
  31. c1 : tmmxword = (1,1,1,1);
  32. c2 : tmmxword = (1234,4321,1111,33333);
  33. c3 : tmmxword = (1234,4321,2222,11111);
  34. c4 : tmmxword = (2468,8642,3333,44444);
  35. c5 : tmmxword = ($ffff,$ffff,$ffff,$ffff);
  36. begin
  37. {$mmx+}
  38. { Intel: paddw }
  39. t1:=c2+c3;
  40. if not(equal(t1,c4)) then
  41. do_error(1000);
  42. { Intel: psubw }
  43. t5:=t1-c2;
  44. if not(equal(t5,c3)) then
  45. do_error(1001);
  46. t1:=not(c0);
  47. { does a not }
  48. if not(equal(t1,c5)) then
  49. do_error(1002);
  50. { test the saturation }
  51. {$saturation+}
  52. t1:=c5+c2+c3;
  53. if not(equal(t1,c5)) then
  54. do_error(1003);
  55. t1:=c4-c5-t1;
  56. if not(equal(t1,c0)) then
  57. do_error(1004);
  58. {$saturation-}
  59. end;
  60. begin
  61. if not(is_mmx_cpu) then
  62. begin
  63. writeln('!!!! Warning: You need a mmx capable CPU to run this test !!!!');
  64. halt(0);
  65. end;
  66. writeln('Testing basic tmmxword support');
  67. testmmxword;
  68. writeln('Test succesful');
  69. writeln;
  70. end.