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 ASCII macro */
41 /* MASM doesn't have an ASCIZ macro */
46 /* We need this to distinguish repeat from macros */
49 #else /***********************************************************************/
51 /* Force intel syntax */
52 .intel_syntax noprefix
57 /* Hex numbers need to be in 0x1AB format */
60 /* Macro values need to be marked */
63 /* GAS needs explicit [rip] addressing */
64 #define RIP(address) address##[rip]
66 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
67 #define MACRO(...) .macro __VA_ARGS__
70 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
75 .equ cfa_current_offset
, -8
78 /* ... and .ENDP, replacing ENDP */
84 /* MASM compatible PUBLIC */
85 #define PUBLIC .global
87 /* MASM compatible ALIGN */
90 /* MASM compatible REPEAT, additional ENDR */
94 /* MASM compatible EXTERN */
98 /* MASM needs an END tag */
101 /* Macros for x64 stack unwind OPs */
103 .macro
.allocstack size
104 .cfi_adjust_cfa_offset \size
105 .set cfa_current_offset
, cfa_current_offset
- \size
109 .macro
.pushframe param
=0
111 .cfi_adjust_cfa_offset
0x30
112 .set cfa_current_offset
, cfa_current_offset
- 0x30
114 .cfi_adjust_cfa_offset
0x28
115 .set cfa_current_offset
, cfa_current_offset
- 0x28
120 .cfi_adjust_cfa_offset
8
121 .equ cfa_current_offset
, cfa_current_offset
- 8
122 .cfi_offset
\reg
, cfa_current_offset
125 .macro
.savereg reg
, offset
127 .cfi_offset
\reg
, \offset
130 .macro
.savexmm128 reg
, offset
132 .cfi_offset
\reg
, \offset
135 .macro
.setframe reg
, offset
136 .cfi_def_cfa reg
, \offset
137 .equ cfa_current_offset
, \offset
143 // Note the file1. This is a hack, as "\file" doesn't work with __FILE__, when
144 // .altmacro is specified.
145 .macro UNIMPLEMENTED2 file1
, line
, func
152 lea rcx
, _MsgUnimplemented
[rip
]
159 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
161 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
162 conditionals. We therefore use "if", too. .if shouldn't be used at all */