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 */
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 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
64 #define MACRO(...) .macro __VA_ARGS__
67 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
72 .equ cfa_current_offset
, -8
75 /* ... and .ENDP, replacing ENDP */
81 /* MASM compatible PUBLIC */
82 #define PUBLIC .global
84 /* MASM compatible ALIGN */
87 /* MASM compatible REPEAT, additional ENDR */
91 /* MASM compatible EXTERN */
95 /* MASM needs an END tag */
98 /* Macros for x64 stack unwind OPs */
100 .macro
.allocstack size
101 .cfi_adjust_cfa_offset \size
102 .set cfa_current_offset
, cfa_current_offset
- \size
106 .macro
.pushframe param
=0
108 .cfi_adjust_cfa_offset
0x30
109 .set cfa_current_offset
, cfa_current_offset
- 0x30
111 .cfi_adjust_cfa_offset
0x28
112 .set cfa_current_offset
, cfa_current_offset
- 0x28
117 .cfi_adjust_cfa_offset
8
118 .equ cfa_current_offset
, cfa_current_offset
- 8
119 .cfi_offset
\reg
, cfa_current_offset
122 .macro
.savereg reg
, offset
124 .cfi_offset
\reg
, \offset
127 .macro
.savexmm128 reg
, offset
129 .cfi_offset
\reg
, \offset
132 .macro
.setframe reg
, offset
133 .cfi_def_cfa reg
, \offset
134 .equ cfa_current_offset
, \offset
140 // Note the file1. This is a hack, as "\file" doesn't work with __FILE__, when
141 // .altmacro is specified.
142 .macro UNIMPLEMENTED2 file1
, line
, func
149 lea rcx
, _MsgUnimplemented
[rip
]
156 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
158 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
159 conditionals. We therefore use "if", too. .if shouldn't be used at all */