Hi there,

It's been a while but I'm still plugging away at learning assembly language. It's time for some x87 maths and I'm as I'm targetting x86_64, debugging using printf means storing the values in the FPU ST registers in the XMM registers. So far I've been to storing the values to memory and thence to the XMM registers.

The tutorial (written for 32-bit x86) is unsurprisingly silent on the issue and Google searches have proven fruitless. What is the accepted way of copying values from the ST to the XMM registers?


Posted on 2011-11-30 16:32:24 by michaelg

This manual provides tons of info on x64 FPU:

Posted on 2011-11-30 16:53:47 by p1ranha
Thanks P1ranha, it's a mine of information. However, having looked through it, it still seems to me that there's no single-instruction method of moving a value from st(0) to xmm0 without detouring to at least the x86 stack. The movd instruction would serve to move a value from a general-purprose register to xmm0, but it's getting the data from st(0) into the gp register that has me stumped (or indeed directly from st(0) to xmm0). Any takers?
Posted on 2011-12-01 05:40:18 by michaelg
I am not an XMM expert by any means.  However, you can easily fst or fstp to get the FPU stack value into memory then load a gp register from there.  Will that help?
Posted on 2011-12-01 06:50:20 by p1ranha
Yes, that's currently what I'm doing. I had (perhaps naively) thought that it would be possible to copy a value from st(0) to xmm0 in one operation, but it's starting to look like a detour via memory is required.
Posted on 2011-12-01 10:29:51 by michaelg
Afaik there isn't a way to access the FPU stack directly via SSE.
You should not use the FPU at all, when using SSE2+ (when SSE2 was introduced on Pentium 4, FPU was emulated on the SSE2 units via microcode anyway, so a big performance hazard).
In fact, under 64-bit OSes, the use of the FPU is deprecated.
Posted on 2011-12-05 08:30:07 by Scali
Hi Scali,

Thanks for your reply. Like trying to prove a negative, searching for something which isn't there is pretty difficult...

I should probably say that I'm simply working through the tutorial's in Blum's book (I don't even see the % signs anymore) and my interest in the x87 FPU is related to the material rather than a desire to use it in anger!


Posted on 2011-12-05 10:14:47 by michaelg