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
114 .fill MACRO repeat, size, value
118 ljmp MACRO segment, offset
122 UNIMPLEMENTED MACRO name
125 /* We need this to distinguish repeat from macros */
128 #else /***********************************************************************/
130 /* Force intel syntax */
131 .intel_syntax noprefix
135 /* Hex numbers need to be in 0x1AB format */
138 /* Macro values need to be marked */
141 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
142 #define MACRO(...) .macro __VA_ARGS__
145 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
150 .equ cfa_current_offset, -8
153 /* ... and .ENDP, replacing ENDP */
159 /* MASM compatible PUBLIC */
165 .macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8
168 /* MASM needs an end tag for segments */
172 /* MASM compatible ALIGN */
175 /* MASM compatible REPEAT, additional ENDR */
179 .macro ljmp segment, offset
180 jmp far ptr \segment:\offset
183 /* MASM compatible EXTERN */
187 /* MASM needs an END tag */
197 /* Macros for x64 stack unwind OPs */
199 .macro .allocstack size
200 .cfi_adjust_cfa_offset \size
201 .set cfa_current_offset, cfa_current_offset - \size
205 .macro .pushframe param=0
207 .cfi_adjust_cfa_offset 0x30
208 .set cfa_current_offset, cfa_current_offset - 0x30
210 .cfi_adjust_cfa_offset 0x28
211 .set cfa_current_offset, cfa_current_offset - 0x28
216 .cfi_adjust_cfa_offset 8
217 .equ cfa_current_offset, cfa_current_offset - 8
218 .cfi_offset \reg, cfa_current_offset
221 .macro .savereg reg, offset
223 .cfi_offset \reg, \offset
226 .macro .savexmm128 reg, offset
228 .cfi_offset \reg, \offset
231 .macro .setframe reg, offset
232 .cfi_def_cfa reg, \offset
233 .equ cfa_current_offset, \offset
239 .macro UNIMPLEMENTED2 file, line, func
246 lea rcx, MsgUnimplemented[rip]
253 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
255 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
256 conditionals. We therefore use "if", too. .if shouldn't be used at all */
260 #define elseif .elseif