The MASM Forum

General => The Workshop => Topic started by: daydreamer on May 06, 2018, 07:02:21 PM

Title: Re: PUSH & POP question
Post by: daydreamer on May 06, 2018, 07:02:21 PM
it would be nice to make use of the real stack, instead of a fake one when it comes to SIMD regs,so how do I change this code to make use of EBP to put it on real stack?
printing .xmm regs would be easy to "push" on stack and 4 unrolled calls to print that

.data?
    statestack  dd 0 dup (65536)
                dd 0 dup (65536)
.code
;ebx is initialized to make use of statestack



PUSHSTATE MACRO
    FXSAVE [ebx]
    add ebx,512
    ENDM
    POPSTATE MACRO
    sub ebx,512
    FXRSTOR [ebx]
   
    ENDM
;macro is on purpose written without spacebar to avoid conflict with keyword PUSH/POP
PUSHXMM1 MACRO
    movaps [ebx],xmm1
    add ebx,16
    ENDM
POPXMM1 MACRO
   movaps xmm1,[ebx]
   sub ebx,16
   ENDM

Title: Re: Re: PUSH & POP question
Post by: jj2007 on May 06, 2018, 07:47:56 PM
Quote from: daydreamer on May 06, 2018, 07:02:21 PM
it would be nice to make use of the real stack, instead of a fake one when it comes to SIMD regs,so how do I change this code to make use of EBP to put it on real stack?

Your macros are nice, but you could simply declare local OWORD variables (you need a modern assembler like UAsm (http://www.terraspace.co.uk/uasm.html#p2)).

P.S.: I couldn't resist - Push & Pop xmm registers (http://masm32.com/board/index.php?topic=6483.msg76863#msg76863) (thanks for the inspiration ;))
Title: Re: PUSH & POP question
Post by: daydreamer on May 07, 2018, 12:36:34 AM
thats great idea for macros JJ
its old macros from 2006
you missed my earlier posting January
http://masm32.com/board/index.php?topic=6802.0 (http://masm32.com/board/index.php?topic=6802.0)


PUSHSTATE MACRO
    FXSAVE [ebx]
    add ebx,512
    ENDM
    POPSTATE MACRO
    sub ebx,512
    FXRSTOR [ebx]
   
    ENDM
;new versions of the original idea
POPSTATE2 MACRO
    movaps XMM0,[ebx]
    movaps XMM1,[ebx+16]
    movaps XMM2,[ebx+32]
    movaps XMM3,[ebx+48]
    movaps XMM4,[ebx+64]
    movaps XMM5,[ebx+80]
    movaps XMM6,[ebx+96]
    movaps XMM7,[ebx+112]
    sub ebx,128
    ENDM

PUSHSTATE2 MACRO
    movaps [ebx],XMM0
    movaps [ebx+16],XMM1
    movaps [ebx+32],XMM2
    movaps [ebx+48],XMM3
    movaps [ebx+64],XMM4
    movaps [ebx+80],XMM5
    movaps [ebx+96],XMM6
    movaps [ebx+112],XMM7
    add ebx,128
    ENDM