Push XMM register to the stack

后端 未结 2 1955
再見小時候
再見小時候 2021-02-02 15:41

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

相关标签:
2条回答
  • 2021-02-02 15:57

    I’d recommend to use a separate, 16-bit aligned stack for this purpose, so you can use movdqa instead of movdqu. There is a slight difference in execution time between these 2 instructions!

    0 讨论(0)
  • 2021-02-02 16:17

    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!

    0 讨论(0)
提交回复
热议问题