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 */
16 ASSUME CS
:NOTHING
, DS
:NOTHING
, ES
:NOTHING
, FS
:NOTHING
, GS
:NOTHING
18 /* Hex numbers need to be in 01ABh format */
19 #define HEX(x) 0##x##h
21 /* Macro values need to be marked */
24 /* MASM/ML doesn't want explicit [rip] addressing */
27 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
28 #define MACRO(name, ...) name MACRO __VA_ARGS__
30 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
36 /* ... and .ENDP, replacing ENDP */
41 /* MASM doesn't have an ASCII macro */
46 /* MASM doesn't have an ASCIZ macro */
62 .align MACRO alignment
66 .byte MACRO args
:VARARG
70 .short MACRO args
:VARARG
74 .long MACRO args
:VARARG
78 UNIMPLEMENTED MACRO name
81 /* We need this to distinguish repeat from macros */
84 #else /***********************************************************************/
86 /* Force intel syntax */
87 .intel_syntax noprefix
91 /* Hex numbers need to be in 0x1AB format */
94 /* Macro values need to be marked */
97 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
98 #define MACRO(...) .macro __VA_ARGS__
101 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
106 .equ cfa_current_offset
, -8
109 /* ... and .ENDP, replacing ENDP */
115 /* MASM compatible PUBLIC */
120 /* MASM compatible ALIGN */
123 /* MASM compatible REPEAT, additional ENDR */
127 /* MASM compatible EXTERN */
131 /* MASM needs an END tag */
141 /* Macros for x64 stack unwind OPs */
143 .macro
.allocstack size
144 .cfi_adjust_cfa_offset \size
145 .set cfa_current_offset
, cfa_current_offset
- \size
149 .macro
.pushframe param
=0
151 .cfi_adjust_cfa_offset
0x30
152 .set cfa_current_offset
, cfa_current_offset
- 0x30
154 .cfi_adjust_cfa_offset
0x28
155 .set cfa_current_offset
, cfa_current_offset
- 0x28
160 .cfi_adjust_cfa_offset
8
161 .equ cfa_current_offset
, cfa_current_offset
- 8
162 .cfi_offset
\reg
, cfa_current_offset
165 .macro
.savereg reg
, offset
167 .cfi_offset
\reg
, \offset
170 .macro
.savexmm128 reg
, offset
172 .cfi_offset
\reg
, \offset
175 .macro
.setframe reg
, offset
176 .cfi_def_cfa reg
, \offset
177 .equ cfa_current_offset
, \offset
183 .macro UNIMPLEMENTED2 file
, line
, func
190 lea rcx
, MsgUnimplemented
[rip
]
197 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
199 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
200 conditionals. We therefore use "if", too. .if shouldn't be used at all */
204 #define elseif .elseif