Author Topic: Dynamic LOCAL alignment for XMM registers.  (Read 1079 times)

hutch--

  • Administrator
  • Member
  • ******
  • Posts: 7794
  • Mnemonic Driven API Grinder
    • The MASM32 SDK
Dynamic LOCAL alignment for XMM registers.
« on: September 15, 2018, 01:42:10 PM »
Seems to work OK and easy enough to set up.

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    include \masm32\include64\masm64rt.inc

    ssealign MACRO buffer
      lea rax, buffer
      memalign rax, 16
      EXITM <rax>
    ENDM

    .code

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

 entry_point proc

    call testit

    conout lf,"  If you can see me, it worked.",lf,lf

    waitkey
    .exit

 entry_point endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

 testit proc

    LOCAL pmem  :QWORD
    LOCAL buff[256]:BYTE

    mov pmem, ssealign(buff)

    mov r10, pmem                           ; load aligned address into register

    movdqa XMMWORD PTR [r10], xmm12
    movdqa XMMWORD PTR [r10+16], xmm13
    movdqa XMMWORD PTR [r10+32], xmm14
    movdqa XMMWORD PTR [r10+48], xmm15

    nop
    nop                                     ; your code goes here
    nop

    movntdqa xmm12, XMMWORD PTR [r10]
    movntdqa xmm13, XMMWORD PTR [r10+16]
    movntdqa xmm14, XMMWORD PTR [r10+32]
    movntdqa xmm15, XMMWORD PTR [r10+48]

    ret

 testit endp

; ¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤¤

    end
hutch at movsd dot com
http://www.masm32.com    :biggrin:  :skrewy:

jj2007

  • Member
  • *****
  • Posts: 10845
  • Assembler is fun ;-)
    • MasmBasic
Re: Dynamic LOCAL alignment for XMM registers.
« Reply #1 on: September 15, 2018, 06:10:33 PM »
Code: [Select]
  nop                                     ; your code goes herepush+pop not allowed here...