The MASM Forum

General => The Laboratory => Topic started by: hutch-- on September 15, 2018, 01:42:10 PM

Title: Dynamic LOCAL alignment for XMM registers.
Post by: hutch-- 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
Title: Re: Dynamic LOCAL alignment for XMM registers.
Post by: jj2007 on September 15, 2018, 06:10:33 PM
  nop                                     ; your code goes here
push+pop not allowed here...