News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Save and restore YMM regs

Started by hutch--, August 16, 2020, 06:27:12 PM

Previous topic - Next topic

hutch--

YMM aligned proc, save YMM regs above YMM7, work with 16 YMM regs.

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

    include \masm32\include64\masm64rt.inc

    .code

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

entry_point proc

    USING r12

    SaveRegs

    conout "Save and restore YMM registers .",lf,lf

    call ymmproc

    waitkey
    RestoreRegs
    .exit

entry_point endp

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

YMMSTACK                                ; YMM alignment

ymmproc proc

    LOCAL ymmvar1 :YMMWORD              ; aligned LOCAL variables
    LOCAL ymmvar2 :YMMWORD
    LOCAL ymmvar3 :YMMWORD
    LOCAL ymmvar4 :YMMWORD
    LOCAL ymmvar5 :YMMWORD
    LOCAL ymmvar6 :YMMWORD
    LOCAL ymmvar7 :YMMWORD
    LOCAL ymmvar8 :YMMWORD

    vmovntdq ymmvar1, ymm8              ; preserve YMM registers
    vmovntdq ymmvar2, ymm9
    vmovntdq ymmvar3, ymm10
    vmovntdq ymmvar4, ymm11
    vmovntdq ymmvar5, ymm12
    vmovntdq ymmvar6, ymm13
    vmovntdq ymmvar7, ymm14
    vmovntdq ymmvar8, ymm15

  ; -------------------------------------
  ; just do it here with 16 YMM registers
  ; -------------------------------------

    vmovntdqa ymm8,  ymmvar1            ; restore YMM registers
    vmovntdqa ymm9,  ymmvar2
    vmovntdqa ymm10, ymmvar3
    vmovntdqa ymm11, ymmvar4
    vmovntdqa ymm12, ymmvar5
    vmovntdqa ymm13, ymmvar6
    vmovntdqa ymm14, ymmvar7
    vmovntdqa ymm15, ymmvar8

    ret

ymmproc endp

STACKFRAME

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

    end