Author Topic: Re: PUSH & POP question  (Read 370 times)

daydreamer

  • Member
  • ****
  • Posts: 548
  • reach for the stars
Re: PUSH & POP question
« 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
Code: [Select]
.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

Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*

jj2007

  • Member
  • *****
  • Posts: 8773
  • Assembler is fun ;-)
    • MasmBasic
Re: Re: PUSH & POP question
« Reply #1 on: May 06, 2018, 07:47:56 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).

P.S.: I couldn't resist - Push & Pop xmm registers (thanks for the inspiration ;))

daydreamer

  • Member
  • ****
  • Posts: 548
  • reach for the stars
Re: PUSH & POP question
« Reply #2 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


Code: [Select]
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
Quote from Flashdance
Nick  :  When you give up your dream, you die.
*wears a flameproof asbestos suit*