tmmx1.pp 1.5 KB

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