PageRenderTime 28ms CodeModel.GetById 12ms app.highlight 13ms RepoModel.GetById 0ms app.codeStats 0ms

/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
Possible License(s): BSD-3-Clause
  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
 30#pragma hdrstop
 31
 32#include <iostream>
 33#include <iomanip>
 34
 35//---------------------------------------------------------------------------
 36
 37#if __BORLANDC__ == 1380
 38#define BCB6
 39#endif
 40
 41#if __BORLANDC__ == 1360
 42#define BCB5
 43#endif
 44
 45#ifdef BCB5
 46#define COMPILER5_UP
 47#define COMPILER5
 48#endif
 49
 50#ifdef BCB6
 51#define COMPILER6_UP
 52#define COMPILER5_UP
 53#define COMPILER6
 54#endif
 55
 56#pragma argsused
 57int main (int argc, char **argv)
 58{
 59  using namespace std;
 60  float Values[4];
 61  int Index, ErrorCode;
 62  char Line[256];
 63
 64  printf("Streaming SIMD Extensions of Intel Pentium and AMD Athlon processors\n");
 65  printf("By Ouchet Florent <outchy_at_users.sourceforge.net>\n");
 66  printf("Released 2004,14,3\n");
 67  printf("All rights free\n\n");
 68
 69  for (Index=0; Index<4; Index++) {
 70    do {
 71      printf("Enter the floating point value %d : ",Index);
 72      gets(Line);
 73      ErrorCode = sscanf(Line,"%f",Values+Index);
 74    } while (ErrorCode!=1);
 75  }
 76
 77  printf("\nCheck values :\n");
 78  for (Index=0; Index<4; Index++)
 79    printf("Value %d is : %f\n",Index,Values[Index]);
 80
 81  printf("\nStarting computations : Values*2 ...");
 82  __asm {
 83    // breakpoint here
 84    // hit ctrl+alt+D or go to View/Debug window and open the last item
 85    // these instructions operate on 4-packed-single-precision floating point values
 86    // so you should view these registers has single values
 87    LEA      EAX,  Values
 88#ifdef COMPILER6_UP
 89    movups   xmm0, [eax]      // moving Values to xmm0
 90    addps    xmm0, xmm0       // xmm0 <- xmm0 + xmm0
 91    movups   [eax], xmm0      // moving xmm0 to Values
 92#else
 93    DB       0Fh, 10h, 00h    // movups xmm0, [eax]
 94    DB       0Fh, 58h, 0C0h   // addps xmm0, xmm0
 95    DB       0Fh, 11h, 00h    // movups [eax], xmm0
 96#endif
 97  };
 98  printf("Computations ended\nNow values are :\n");
 99  for (Index=0; Index<4; Index++)
100    printf("Value %d is : %f\n",Index,Values[Index]);
101  printf("\nProgram terminated\n");
102  gets(Line);
103  return 0;
104}
105//---------------------------------------------------------------------------