Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Push XMM register to the stack

Is there a way of pushing a packed doubleword integer from XMM register to the stack? and then later on pop it back when needed?

Ideally I am looking for something like PUSH or POP for general purpose registers, I have checked Intel manuals but I either missed the command or there isn't one...

Or will I have to unpack values to general registers and then push them?

like image 827
Daniel Gruszczyk Avatar asked Apr 15 '12 12:04

Daniel Gruszczyk


People also ask

How do I register with XMM?

XMM registers, instead, are a completely separate registers set, introduced with SSE and still widely used to this day. They are 128 bit wide, with instructions that can treat them as arrays of 64, 32 (integer and floating point),16 or 8 bit (integer only) values. You have 8 of them in 32 bit mode, 16 in 64 bit.


Video Answer


1 Answers

No, there is no such a asm instruction under x86, but you can do something like:

//Push xmm0
sub     esp, 16
movdqu  dqword [esp], xmm0

//Pop xmm0
movdqu  xmm0, dqword [esp]
add     esp, 16

EDIT:

Upper code sample is direct push/pop emulation.

In case that you are using on stack also other local variables, than the ebp register must be at first properly set, like:

push ebp
mov  ebp, esp
sub  esp, LocaStackVariablesSize
//... your code
mov  esp, ebp
pop  ebp  
ret

In that case you can also use Daniels solution!

like image 133
GJ. Avatar answered Sep 19 '22 05:09

GJ.