xref: /reactos/sdk/include/asm/macamd64.inc (revision a1fc312a)
1/*
2 * PROJECT:     ReactOS SDK
3 * LICENSE:     GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE:     ReactOS AMD64 architecture asm macros
5 * COPYRIGHT:   Timo Kreuzer (timo.kreuzer@reactos.org)
6 */
7
8#include <asm.inc>
9
10MACRO(push_reg, Reg)
11    push Reg
12    .pushreg Reg
13ENDM
14
15MACRO(rex_push_reg, Reg)
16    db HEX(048) ; REX prefix
17    push Reg
18    .pushreg Reg
19ENDM
20
21MACRO(push_eflags)
22    pushfq
23    .allocstack 8
24ENDM
25
26MACRO(rex_push_eflags)
27    db HEX(048) ; REX prefix
28    pushfq
29    .allocstack 8
30ENDM
31
32MACRO(rex_jmp_reg, Reg)
33    db HEX(048) ; REX prefix / hint tail call to unwinder
34    jmp Reg
35ENDM
36
37MACRO(ret_zero)
38    ret
39ENDM
40
41MACRO(alloc_stack, Size)
42    sub rsp, Size
43    .allocstack Size
44ENDM
45
46MACRO(save_reg, Reg, Offset)
47    mov [rsp + Offset], Reg
48    .savereg Reg, Offset
49ENDM
50
51MACRO(save_xmm128, Reg, Offset)
52    movaps  [rsp + Offset], Reg
53    .savexmm128 Reg, Offset
54ENDM
55
56MACRO(push_frame, Code)
57    .pushframe Code
58ENDM
59
60MACRO(set_frame, Reg, Offset)
61    if Offset
62        lea Reg, [rsp + Offset]
63    else
64        mov Reg, rsp
65    endif
66    .setframe Reg, Offset
67ENDM
68
69MACRO(END_PROLOGUE)
70    .endprolog
71ENDM
72
73MACRO(BEGIN_EPILOGUE)
74    .beginepilog
75ENDM
76
77MACRO(LEAF_ENTRY, Name, Section, NoPad)
78    Section segment para 'CODE'
79    ifb <NoPad>
80        db 6 dup HEX(CC)
81    endif
82    align 16
83    public  Name
84Name    proc    frame
85    END_PROLOGUE
86ENDM
87
88MACRO(LEAF_ENTRY_ARG1, Name, Section, Arg1, NoPad)
89    Section segment para 'CODE'
90    ifb <NoPad>
91        db 6 dup HEX(CC)
92    endif
93    align 16
94    public  Name
95Name    proc    frame
96    END_PROLOGUE
97ENDM
98
99MACRO(LEAF_ENTRY_ARG2, Name, Section, Arg1, Arg2, NoPad)
100    Section segment para 'CODE'
101    ifb <NoPad>
102        db 6 dup HEX(CC)
103    endif
104    align 16
105    public  Name
106Name    proc    frame
107    END_PROLOGUE
108ENDM
109
110MACRO(LEAF_ENTRY_ARG3, Name, Section, Arg1, Arg2, Arg3, NoPad)
111    Section segment para 'CODE'
112    ifb <NoPad>
113        db 6 dup HEX(CC)
114    endif
115    align 16
116    public  Name
117Name    proc    frame
118    END_PROLOGUE
119ENDM
120
121MACRO(LEAF_END, Name, section)
122    Name    endp
123    Section ends
124ENDM
125
126MACRO(NESTED_ENTR, Name, Section, Handler, NoPad)
127    ifdef _CurrentSection_
128        ifdif <Section>, _CurrentSection_
129            .err <NESTED_ENTRY invoked for different sections within same module>
130        endif
131    endif
132    _CurrentSection_ EQU <Section>
133    Section segment para 'CODE'
134    ifb <NoPad>
135        db      6 dup (0cch)
136    endif
137    align   16
138    public  Name
139    ifb <Handler>
140Name    proc    frame
141    else
142Name    proc    frame:Handler
143    endif
144ENDM
145
146MACRO(NESTED_END, Name, section)
147Name    endp
148Section ends
149ENDM
150
151MACRO(ALTERNATE_ENTRY, Name)
152Name:
153ENDM
154
155MACRO(Yield)
156    pause
157ENDM
158
159/* EOF */
160