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 ASSUME CS
:NOTHING
, DS
:NOTHING
, ES
:NOTHING
, FS
:NOTHING
, GS
:NOTHING
19 /* Hex numbers need to be in 01ABh format */
20 #define HEX(x) 0##x##h
22 /* Macro values need to be marked */
25 /* MASM/ML doesn't want explicit [rip] addressing */
28 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
29 #define MACRO(name, ...) name MACRO __VA_ARGS__
31 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
37 /* ... and .ENDP, replacing ENDP */
42 /* MASM doesn't have an ASCII macro */
47 /* MASM doesn't have an ASCIZ macro */
63 .align MACRO alignment
67 .byte MACRO args
:VARARG
71 .short MACRO args
:VARARG
75 .long MACRO args
:VARARG
79 .double MACRO args
:VARARG
83 UNIMPLEMENTED MACRO name
86 /* We need this to distinguish repeat from macros */
89 #else /***********************************************************************/
91 /* Force intel syntax */
92 .intel_syntax noprefix
96 /* Hex numbers need to be in 0x1AB format */
99 /* Macro values need to be marked */
102 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
103 #define MACRO(...) .macro __VA_ARGS__
106 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
111 .equ cfa_current_offset
, -8
114 /* ... and .ENDP, replacing ENDP */
120 /* MASM compatible PUBLIC */
126 .macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8
129 /* MASM compatible ALIGN */
132 /* MASM compatible REPEAT, additional ENDR */
136 /* MASM compatible EXTERN */
140 /* MASM needs an END tag */
150 /* Macros for x64 stack unwind OPs */
152 .macro
.allocstack size
153 .cfi_adjust_cfa_offset \size
154 .set cfa_current_offset
, cfa_current_offset
- \size
158 .macro
.pushframe param
=0
160 .cfi_adjust_cfa_offset
0x30
161 .set cfa_current_offset
, cfa_current_offset
- 0x30
163 .cfi_adjust_cfa_offset
0x28
164 .set cfa_current_offset
, cfa_current_offset
- 0x28
169 .cfi_adjust_cfa_offset
8
170 .equ cfa_current_offset
, cfa_current_offset
- 8
171 .cfi_offset
\reg
, cfa_current_offset
174 .macro
.savereg reg
, offset
176 .cfi_offset
\reg
, \offset
179 .macro
.savexmm128 reg
, offset
181 .cfi_offset
\reg
, \offset
184 .macro
.setframe reg
, offset
185 .cfi_def_cfa reg
, \offset
186 .equ cfa_current_offset
, \offset
192 .macro UNIMPLEMENTED2 file
, line
, func
199 lea rcx
, MsgUnimplemented
[rip
]
206 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
208 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
209 conditionals. We therefore use "if", too. .if shouldn't be used at all */
213 #define elseif .elseif