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 */
18 ASSUME CS:NOTHING, DS:NOTHING, ES:NOTHING, FS:NOTHING, GS:NOTHING
21 /* Hex numbers need to be in 01ABh format */
22 #define HEX(x) 0##x##h
24 /* Macro values need to be marked */
27 /* MASM/ML doesn't want explicit [rip] addressing */
30 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
31 #define MACRO(name, ...) name MACRO __VA_ARGS__
33 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
39 /* ... and .ENDP, replacing ENDP */
44 /* MASM doesn't have an ASCII macro */
49 /* MASM doesn't have an ASCIZ macro */
54 #define lgdt lgdt fword ptr ds:
56 #define lidt lidt fword ptr ds:
58 ljmp MACRO segment, offset
88 .align MACRO alignment
92 .byte MACRO args:VARARG
96 .short MACRO args:VARARG
100 .word MACRO args:VARARG
104 .long MACRO args:VARARG
108 .double MACRO args:VARARG
116 .fill MACRO count, size, value
133 ljmp MACRO segment, offset
139 ljmp16 MACRO segment, offset
145 UNIMPLEMENTED MACRO name
148 /* We need this to distinguish repeat from macros */
151 #else /***********************************************************************/
153 /* Force intel syntax */
154 .intel_syntax noprefix
158 /* Hex numbers need to be in 0x1AB format */
161 /* Macro values need to be marked */
164 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
165 #define MACRO(...) .macro __VA_ARGS__
168 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
173 .equ cfa_current_offset, -8
176 /* ... and .ENDP, replacing ENDP */
182 /* MASM compatible PUBLIC */
188 .macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8
191 /* MASM needs an end tag for segments */
195 /* MASM compatible ALIGN */
198 /* MASM compatible REPEAT, additional ENDR */
202 .macro ljmp segment, offset
203 jmp far ptr \segment:\offset
206 .macro ljmp16 segment, offset
207 jmp far ptr \segment:\offset
210 /* MASM compatible EXTERN */
214 /* MASM needs an END tag */
224 /* Macros for x64 stack unwind OPs */
226 .macro .allocstack size
227 .cfi_adjust_cfa_offset \size
228 .set cfa_current_offset, cfa_current_offset - \size
232 .macro .pushframe param=0
234 .cfi_adjust_cfa_offset 0x30
235 .set cfa_current_offset, cfa_current_offset - 0x30
237 .cfi_adjust_cfa_offset 0x28
238 .set cfa_current_offset, cfa_current_offset - 0x28
243 .cfi_adjust_cfa_offset 8
244 .equ cfa_current_offset, cfa_current_offset - 8
245 .cfi_offset \reg, cfa_current_offset
248 .macro .savereg reg, offset
250 .cfi_offset \reg, \offset
253 .macro .savexmm128 reg, offset
255 .cfi_offset \reg, \offset
258 .macro .setframe reg, offset
259 .cfi_def_cfa reg, \offset
260 .equ cfa_current_offset, \offset
266 .macro UNIMPLEMENTED2 file, line, func
273 lea rcx, MsgUnimplemented[rip]
280 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
282 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
283 conditionals. We therefore use "if", too. .if shouldn't be used at all */
287 #define elseif .elseif