2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel
4 * FILE: ntoskrnl/include/amd64/asmmacro.S
5 * PURPOSE: ASM macros for for GAS and MASM/ML64
6 * PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
11 /* Allow ".name" identifiers */
17 /* Hex numbers need to be in 01ABh format */
18 #define HEX(x) 0##x##h
20 /* Macro values need to be marked */
23 /* MASM/ML doesn't want explicit [rip] addressing */
26 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
27 #define MACRO(name, ...) name MACRO __VA_ARGS__
29 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
35 /* ... and .ENDP, replacing ENDP */
40 /* MASM doesn't have an ASCII macro */
45 /* MASM doesn't have an ASCIZ macro */
61 UNIMPLEMENTED MACRO name
64 /* We need this to distinguish repeat from macros */
67 #else /***********************************************************************/
69 /* Force intel syntax */
70 .intel_syntax noprefix
75 /* Hex numbers need to be in 0x1AB format */
78 /* Macro values need to be marked */
81 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
82 #define MACRO(...) .macro __VA_ARGS__
85 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
90 .equ cfa_current_offset
, -8
93 /* ... and .ENDP, replacing ENDP */
99 /* MASM compatible PUBLIC */
104 /* MASM compatible ALIGN */
107 /* MASM compatible REPEAT, additional ENDR */
111 /* MASM compatible EXTERN */
115 /* MASM needs an END tag */
125 /* Macros for x64 stack unwind OPs */
127 .macro
.allocstack size
128 .cfi_adjust_cfa_offset \size
129 .set cfa_current_offset
, cfa_current_offset
- \size
133 .macro
.pushframe param
=0
135 .cfi_adjust_cfa_offset
0x30
136 .set cfa_current_offset
, cfa_current_offset
- 0x30
138 .cfi_adjust_cfa_offset
0x28
139 .set cfa_current_offset
, cfa_current_offset
- 0x28
144 .cfi_adjust_cfa_offset
8
145 .equ cfa_current_offset
, cfa_current_offset
- 8
146 .cfi_offset
\reg
, cfa_current_offset
149 .macro
.savereg reg
, offset
151 .cfi_offset
\reg
, \offset
154 .macro
.savexmm128 reg
, offset
156 .cfi_offset
\reg
, \offset
159 .macro
.setframe reg
, offset
160 .cfi_def_cfa reg
, \offset
161 .equ cfa_current_offset
, \offset
167 .macro UNIMPLEMENTED2 file
, line
, func
174 lea rcx
, MsgUnimplemented
[rip
]
181 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
183 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
184 conditionals. We therefore use "if", too. .if shouldn't be used at all */
188 #define elseif .elseif