/jcl/experts/debug/simdview/JclSIMDTestBCB.cpp

https://github.com/the-Arioch/jcl · C++ · 105 lines · 59 code · 12 blank · 34 comment · 6 complexity · 63eb72e3b76cff481989fc12da0ae1aa MD5 · raw file

  1. //{**************************************************************************************************}
  2. //{ }
  3. //{ Project JEDI Code Library (JCL) }
  4. //{ }
  5. //{ The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); }
  6. //{ you may not use this file except in compliance with the License. You may obtain a copy of the }
  7. //{ License at http://www.mozilla.org/MPL/ }
  8. //{ }
  9. //{ Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF }
  10. //{ ANY KIND, either express or implied. See the License for the specific language governing rights }
  11. //{ and limitations under the License. }
  12. //{ }
  13. //{ The Original Code is: JvSIMDTest.dpr, released on 2004-10-11. }
  14. //{ }
  15. //{ The Initial Developer of the Original Code is Florent Ouchet }
  16. //{ [ouchet dott florent att laposte dott net] }
  17. //{ All Rights Free. }
  18. //{ }
  19. //{ You may retrieve the latest version of this file at the Project JEDI's JCL home page, }
  20. //{ located at http://jcl.sourceforge.net }
  21. //{ }
  22. //{**************************************************************************************************}
  23. //{ }
  24. //{ Last modified: $Date:: $ }
  25. //{ Revision: $Rev:: $ }
  26. //{ Author: $Author:: $ }
  27. //{ }
  28. //{**************************************************************************************************}
  29. #pragma hdrstop
  30. #include <iostream>
  31. #include <iomanip>
  32. //---------------------------------------------------------------------------
  33. #if __BORLANDC__ == 1380
  34. #define BCB6
  35. #endif
  36. #if __BORLANDC__ == 1360
  37. #define BCB5
  38. #endif
  39. #ifdef BCB5
  40. #define COMPILER5_UP
  41. #define COMPILER5
  42. #endif
  43. #ifdef BCB6
  44. #define COMPILER6_UP
  45. #define COMPILER5_UP
  46. #define COMPILER6
  47. #endif
  48. #pragma argsused
  49. int main (int argc, char **argv)
  50. {
  51. using namespace std;
  52. float Values[4];
  53. int Index, ErrorCode;
  54. char Line[256];
  55. printf("Streaming SIMD Extensions of Intel Pentium and AMD Athlon processors\n");
  56. printf("By Ouchet Florent <outchy_at_users.sourceforge.net>\n");
  57. printf("Released 2004,14,3\n");
  58. printf("All rights free\n\n");
  59. for (Index=0; Index<4; Index++) {
  60. do {
  61. printf("Enter the floating point value %d : ",Index);
  62. gets(Line);
  63. ErrorCode = sscanf(Line,"%f",Values+Index);
  64. } while (ErrorCode!=1);
  65. }
  66. printf("\nCheck values :\n");
  67. for (Index=0; Index<4; Index++)
  68. printf("Value %d is : %f\n",Index,Values[Index]);
  69. printf("\nStarting computations : Values*2 ...");
  70. __asm {
  71. // breakpoint here
  72. // hit ctrl+alt+D or go to View/Debug window and open the last item
  73. // these instructions operate on 4-packed-single-precision floating point values
  74. // so you should view these registers has single values
  75. LEA EAX, Values
  76. #ifdef COMPILER6_UP
  77. movups xmm0, [eax] // moving Values to xmm0
  78. addps xmm0, xmm0 // xmm0 <- xmm0 + xmm0
  79. movups [eax], xmm0 // moving xmm0 to Values
  80. #else
  81. DB 0Fh, 10h, 00h // movups xmm0, [eax]
  82. DB 0Fh, 58h, 0C0h // addps xmm0, xmm0
  83. DB 0Fh, 11h, 00h // movups [eax], xmm0
  84. #endif
  85. };
  86. printf("Computations ended\nNow values are :\n");
  87. for (Index=0; Index<4; Index++)
  88. printf("Value %d is : %f\n",Index,Values[Index]);
  89. printf("\nProgram terminated\n");
  90. gets(Line);
  91. return 0;
  92. }
  93. //---------------------------------------------------------------------------