Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / .NET SDK / November 2004

Tip: Looking for answers? Try searching our database.

sth wrong with SSE2 instruction of VC7??

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Deng - 15 Nov 2004 23:21 GMT
Have a short test code for SSE2 instruction.

#include <windows.h>
#include <emmintrin.h>

int _tmain(int argc, _TCHAR* argv[])
{
 const __m128d  data1= {0, 0};
 const __m128d  data2= {1, 1};

  _asm
   {
       movapd xmm0, data1
       movapd xmm1, data2
   
        cvtpd2pi mm0, xmm1
        cvtpi2pd xmm0, mm0
   }

      double i=0;
       i=i+1; //Debug and look at value of i !!!

      return 1;
}

Compile and run it, it seems everything fine, but when I debug into the
code, in the line   i=i+1;
you will find the value of i  showing as " -1.#IND000000000000"

The problem is  caused by  " cvtpd2pi mm0, xmm1", if you comment these two
lines, nothing wrong with i. It seems to me instruction cvtpd2pi ruin the
stack.

Help, please!
Niki Estner - 16 Nov 2004 11:06 GMT
> Have a short test code for SSE2 instruction.
>
[quoted text clipped - 28 lines]
> lines, nothing wrong with i. It seems to me instruction cvtpd2pi ruin the
> stack.

AFAIK This is not a compiler issue: MMX, SSE and SSE2 use the FPU stack to
store their data registers: After using one of these, you'll need an "emms"
instruction to reset the FPU registers.

The problem was that intel didn't want to add new registers to it's pentium
processor, as all OSs which use task switching (i.e. all) rely on the
current register set, so they decided to use the FPU stack. To prevent FPU
operations on a damaged stack, the FPU is set to some kind of special state.

Try:
   _asm
   {
       movapd xmm0, data1
       movapd xmm1, data2

        cvtpd2pi mm0, xmm1
        cvtpi2pd xmm0, mm0

        emms
   }

      double i=0;
       i=i+1; //Debug and look at value of i !!!

Works fine on my PC.

Niki
Deng - 16 Nov 2004 18:23 GMT
Thanks a loooooot, Niki!
Now I see what happened

> > Have a short test code for SSE2 instruction.
> >
[quoted text clipped - 56 lines]
>
> Niki

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.