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 */
14 /* Hex numbers need to be in 01ABh format */
15 #define HEX(x) 0##x##h
17 /* MASM/ML doesn't want explicit [rip] addressing */
18 #define RIP(address) address
20 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
21 #define MACRO(name, ...) name MACRO __VA_ARGS__
23 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
28 /* ... and .ENDP, replacing ENDP */
33 /* MASM doesn't have an ASCIIZ macro */
38 /* We need this to distinguish repeat from macros */
41 #else /***********************************************************************/
43 /* Force intel syntax */
44 .intel_syntax noprefix
47 /* Hex numbers need to be in 0x1AB format */
50 /* GAS needs explicit [rip] addressing */
51 #define RIP(address) address##[rip]
53 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
54 #define MACRO(name, ...) .MACRO name, __VA_ARGS__
56 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
61 .equ cfa_current_offset
, -8
64 /* ... and .ENDP, replacing ENDP */
70 /* MASM compatible PUBLIC */
71 #define PUBLIC .global
73 /* MASM compatible ALIGN */
76 /* MASM compatible REPEAT, additional ENDR */
81 /* Macros for x64 stack unwind OPs */
83 .macro
.allocstack size
84 .cfi_adjust_cfa_offset \size
85 .set cfa_current_offset
, cfa_current_offset
- \size
88 .macro
.pushframe code
90 .cfi_adjust_cfa_offset
0x28
91 .set cfa_current_offset
, cfa_current_offset
- 0x28
93 .cfi_adjust_cfa_offset
0x30
94 .set cfa_current_offset
, cfa_current_offset
- 0x30
99 .cfi_adjust_cfa_offset
8
100 .equ cfa_current_offset
, cfa_current_offset
- 8
101 .cfi_offset
\reg
, cfa_current_offset
104 .macro
.savereg reg
, offset
106 .cfi_offset
\reg
, \offset
109 .macro
.savexmm128 reg
, offset
111 .cfi_offset
\reg
, \offset
114 .macro
.setframe reg
, offset
115 .cfi_def_cfa reg
, \offset
116 .equ cfa_current_offset
, \offset
122 .macro UNIMPLEMENTED2 file
, line
, func
129 lea rcx
, _MsgUnimplemented
[rip
]
136 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
138 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
139 conditionals. We therefore use "if", too. .if shouldn't be used at all */