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 */
14 /* Hex numbers need to be in 01ABh format */
15 #define HEX(x) 0##x##h
17 /* Macro values need to be marked */
20 /* MASM/ML doesn't want explicit [rip] addressing */
23 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
24 #define MACRO(name, ...) name MACRO __VA_ARGS__
26 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
32 /* ... and .ENDP, replacing ENDP */
37 /* MASM doesn't have an ASCII macro */
42 /* MASM doesn't have an ASCIZ macro */
54 UNIMPLEMENTED MACRO name
57 /* We need this to distinguish repeat from macros */
60 #else /***********************************************************************/
62 /* Force intel syntax */
63 .intel_syntax noprefix
68 /* Hex numbers need to be in 0x1AB format */
71 /* Macro values need to be marked */
74 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
75 #define MACRO(...) .macro __VA_ARGS__
78 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
83 .equ cfa_current_offset
, -8
86 /* ... and .ENDP, replacing ENDP */
92 /* MASM compatible PUBLIC */
97 /* MASM compatible ALIGN */
100 /* MASM compatible REPEAT, additional ENDR */
104 /* MASM compatible EXTERN */
108 /* MASM needs an END tag */
111 /* Macros for x64 stack unwind OPs */
113 .macro
.allocstack size
114 .cfi_adjust_cfa_offset \size
115 .set cfa_current_offset
, cfa_current_offset
- \size
119 .macro
.pushframe param
=0
121 .cfi_adjust_cfa_offset
0x30
122 .set cfa_current_offset
, cfa_current_offset
- 0x30
124 .cfi_adjust_cfa_offset
0x28
125 .set cfa_current_offset
, cfa_current_offset
- 0x28
130 .cfi_adjust_cfa_offset
8
131 .equ cfa_current_offset
, cfa_current_offset
- 8
132 .cfi_offset
\reg
, cfa_current_offset
135 .macro
.savereg reg
, offset
137 .cfi_offset
\reg
, \offset
140 .macro
.savexmm128 reg
, offset
142 .cfi_offset
\reg
, \offset
145 .macro
.setframe reg
, offset
146 .cfi_def_cfa reg
, \offset
147 .equ cfa_current_offset
, \offset
153 .macro UNIMPLEMENTED2 file
, line
, func
160 lea rcx
, _MsgUnimplemented
[rip
]
167 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
169 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
170 conditionals. We therefore use "if", too. .if shouldn't be used at all */