testmmx.pp 1.5 KB

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