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 */
52 #define lgdt lgdt fword ptr ds:
54 #define lidt lidt fword ptr ds:
56 ljmp MACRO segment, offset
86 .align MACRO alignment
90 .byte MACRO args:VARARG
94 .short MACRO args:VARARG
98 .word MACRO args:VARARG
102 .long MACRO args:VARARG
106 .double MACRO args:VARARG
110 .fill MACRO repeat, size, value
114 ljmp MACRO segment, offset
118 UNIMPLEMENTED MACRO name
121 /* We need this to distinguish repeat from macros */
124 #else /***********************************************************************/
126 /* Force intel syntax */
127 .intel_syntax noprefix
131 /* Hex numbers need to be in 0x1AB format */
134 /* Macro values need to be marked */
137 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
138 #define MACRO(...) .macro __VA_ARGS__
141 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
146 .equ cfa_current_offset, -8
149 /* ... and .ENDP, replacing ENDP */
155 /* MASM compatible PUBLIC */
161 .macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8
164 /* MASM needs an end tag for segments */
168 /* MASM compatible ALIGN */
171 /* MASM compatible REPEAT, additional ENDR */
175 .macro ljmp segment, offset
176 jmp far ptr \segment:\offset
179 /* MASM compatible EXTERN */
183 /* MASM needs an END tag */
193 /* Macros for x64 stack unwind OPs */
195 .macro .allocstack size
196 .cfi_adjust_cfa_offset \size
197 .set cfa_current_offset, cfa_current_offset - \size
201 .macro .pushframe param=0
203 .cfi_adjust_cfa_offset 0x30
204 .set cfa_current_offset, cfa_current_offset - 0x30
206 .cfi_adjust_cfa_offset 0x28
207 .set cfa_current_offset, cfa_current_offset - 0x28
212 .cfi_adjust_cfa_offset 8
213 .equ cfa_current_offset, cfa_current_offset - 8
214 .cfi_offset \reg, cfa_current_offset
217 .macro .savereg reg, offset
219 .cfi_offset \reg, \offset
222 .macro .savexmm128 reg, offset
224 .cfi_offset \reg, \offset
227 .macro .setframe reg, offset
228 .cfi_def_cfa reg, \offset
229 .equ cfa_current_offset, \offset
235 .macro UNIMPLEMENTED2 file, line, func
242 lea rcx, MsgUnimplemented[rip]
249 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
251 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
252 conditionals. We therefore use "if", too. .if shouldn't be used at all */
256 #define elseif .elseif