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... */
40 /* ... and .ENDP, replacing ENDP */
46 /* MASM doesn't have an ASCII macro */
47 .ASCII MACRO text:VARARG
50 .ascii MACRO text:VARARG
54 /* MASM doesn't have an ASCIZ macro */
55 .ASCIZ MACRO text:VARARG
59 .asciz MACRO text:VARARG
91 .align MACRO alignment
95 .byte MACRO args:VARARG
99 .short MACRO args:VARARG
103 .word MACRO args:VARARG
107 .long MACRO args:VARARG
111 .double MACRO args:VARARG
119 .fill MACRO count, size, value
135 ljmp MACRO segment, offset
141 ljmp16 MACRO segment, offset
147 UNIMPLEMENTED MACRO name
150 absolute MACRO address
151 __absolute__address__ = address
154 resb MACRO name, size
155 name = __absolute__address__
156 __absolute__address__ = __absolute__address__ + size
160 /* We need this to distinguish repeat from macros */
167 #else /***********************************************************************/
169 /* Force intel syntax */
170 .intel_syntax noprefix
174 /* Hex numbers need to be in 0x1AB format */
177 /* Macro values need to be marked */
180 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
181 #define MACRO(...) .macro __VA_ARGS__
184 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
189 .equ cfa_current_offset, -8
192 /* ... and .ENDP, replacing ENDP */
198 /* MASM compatible PUBLIC */
204 .macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8
207 /* MASM needs an end tag for segments */
211 /* MASM compatible ALIGN */
214 /* MASM compatible REPEAT, additional ENDR */
218 .macro ljmp segment, offset
219 jmp far ptr \segment:\offset
222 .macro ljmp16 segment, offset
223 jmp far ptr \segment:\offset
226 /* MASM compatible EXTERN */
230 /* MASM needs an END tag */
240 /* Macros for x64 stack unwind OPs */
242 .macro .allocstack size
243 .cfi_adjust_cfa_offset \size
244 .set cfa_current_offset, cfa_current_offset - \size
248 .macro .pushframe param=0
250 .cfi_adjust_cfa_offset 0x30
251 .set cfa_current_offset, cfa_current_offset - 0x30
253 .cfi_adjust_cfa_offset 0x28
254 .set cfa_current_offset, cfa_current_offset - 0x28
259 .cfi_adjust_cfa_offset 8
260 .equ cfa_current_offset, cfa_current_offset - 8
261 .cfi_offset \reg, cfa_current_offset
264 .macro .savereg reg, offset
266 .cfi_offset \reg, \offset
269 .macro .savexmm128 reg, offset
271 .cfi_offset \reg, \offset
274 .macro .setframe reg, offset
275 .cfi_def_cfa reg, \offset
276 .equ cfa_current_offset, \offset
282 .macro absolute address
283 __absolute__address__ = \address
286 .macro resb name, size
287 \name = __absolute__address__
288 __absolute__address__ = __absolute__address__ + \size
291 .macro UNIMPLEMENTED2 file, line, func
298 lea rcx, MsgUnimplemented[rip]
305 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
307 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
308 conditionals. We therefore use "if", too. .if shouldn't be used at all */
312 #define elseif .elseif