-
Notifications
You must be signed in to change notification settings - Fork 44
/
macros.inc
53 lines (43 loc) · 1.32 KB
/
macros.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
; Use these macros for pushing/popping the general purpose registers
%macro multipush 1-* ; Variadic macro that accepts any number of arguments.
%rep %0 ; %0 means that this proc will repeat as many times as there were arguments
push %1
%rotate 1 ; Shifts arguments left by one (i.e. $3 becomes $2, $2 becomes $1, $1 gets deleted)
%endrep
%endmacro
%macro multipop 1-* ; Symmetric version in order to pop the arguments from the stack.
%rep %0
%rotate -1 ; Orig. last argument now appears as %1. Iterate in reverse order.
pop %1
%endrep
%endmacro
; Use these macros for pushing/popping xmm registers
%macro multipush_xmm 1-*
%rep %0
sub rsp, 16
movdqu oword [rsp], %1 ; note: In NASM, octo-word is used instead of dqword like in MASM.
%rotate 1
%endrep
%endmacro
%macro multipop_xmm 1-*
%rep %0
%rotate -1
movdqu %1, oword [rsp]
add rsp, 16
%endrep
%endmacro
; Use these macros for pushing/popping ymm registers
%macro multipush_ymm 1-*
%rep %0
sub rsp, 32
vmovdqu yword [rsp], %1 ; note: In NASM, octo-word is used instead of dqword like in MASM.
%rotate 1
%endrep
%endmacro
%macro multipop_ymm 1-*
%rep %0
%rotate -1
vmovdqu %1, yword [rsp]
add rsp, 32
%endrep
%endmacro