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 /* Macro values need to be marked */
20 /* MASM/ML doesn't want explicit [rip] addressing */
21 #define RIP(address) address
23 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
24 #define MACRO(name, ...) name MACRO __VA_ARGS__
26 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
31 /* ... and .ENDP, replacing ENDP */
36 /* MASM doesn't have an ASCIIZ macro */
41 /* We need this to distinguish repeat from macros */
44 #else /***********************************************************************/
46 /* Force intel syntax */
47 .intel_syntax noprefix
50 /* Hex numbers need to be in 0x1AB format */
53 /* Macro values need to be marked */
56 /* GAS needs explicit [rip] addressing */
57 #define RIP(address) address##[rip]
59 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
60 #define MACRO(...) .macro __VA_ARGS__
63 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
68 .equ cfa_current_offset
, -8
71 /* ... and .ENDP, replacing ENDP */
77 /* MASM compatible PUBLIC */
78 #define PUBLIC .global
80 /* MASM compatible ALIGN */
83 /* MASM compatible REPEAT, additional ENDR */
87 /* MASM compatible EXTERN */
91 /* MASM needs an END tag */
94 /* Macros for x64 stack unwind OPs */
96 .macro
.allocstack size
97 .cfi_adjust_cfa_offset \size
98 .set cfa_current_offset
, cfa_current_offset
- \size
101 .macro
.pushframe code
103 .cfi_adjust_cfa_offset
0x28
104 .set cfa_current_offset
, cfa_current_offset
- 0x28
106 .cfi_adjust_cfa_offset
0x30
107 .set cfa_current_offset
, cfa_current_offset
- 0x30
112 .cfi_adjust_cfa_offset
8
113 .equ cfa_current_offset
, cfa_current_offset
- 8
114 .cfi_offset
\reg
, cfa_current_offset
117 .macro
.savereg reg
, offset
119 .cfi_offset
\reg
, \offset
122 .macro
.savexmm128 reg
, offset
124 .cfi_offset
\reg
, \offset
127 .macro
.setframe reg
, offset
128 .cfi_def_cfa reg
, \offset
129 .equ cfa_current_offset
, \offset
135 .macro UNIMPLEMENTED2 file
, line
, func
142 lea rcx
, _MsgUnimplemented
[rip
]
149 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
151 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
152 conditionals. We therefore use "if", too. .if shouldn't be used at all */