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... */
39 /* ... and .ENDP, replacing ENDP */
45 /* check http://msdn.microsoft.com/en-us/library/9c9k076y%28VS.80%29.aspx
46 and http://msdn.microsoft.com/en-us/library/ms679352%28VS.85%29.aspx */
47 FPO MACRO cdwLocals, cdwParams, cbProlog, cbRegs, fUseBP, cbFrame
48 .FPO (cdwLocals, cdwParams, cbProlog, cbRegs, fUseBP, cbFrame)
51 /* MASM doesn't have an ASCII macro */
52 .ASCII MACRO text:VARARG
55 .ascii MACRO text:VARARG
59 /* MASM doesn't have an ASCIZ macro */
60 .ASCIZ MACRO text:VARARG
64 .asciz MACRO text:VARARG
96 .align MACRO alignment
100 .byte MACRO args:VARARG
104 .short MACRO args:VARARG
108 .word MACRO args:VARARG
112 .long MACRO args:VARARG
116 .double MACRO args:VARARG
124 .fill MACRO count, size, value
140 ljmp MACRO segment, offset
146 ljmp16 MACRO segment, offset
152 UNIMPLEMENTED MACRO name
155 absolute MACRO address
156 __absolute__address__ = address
159 resb MACRO name, size
160 name = __absolute__address__
161 __absolute__address__ = __absolute__address__ + size
165 /* We need this to distinguish repeat from macros */
172 #else /***********************************************************************/
174 /* Force intel syntax */
175 .intel_syntax noprefix
179 /* Hex numbers need to be in 0x1AB format */
182 /* Macro values need to be marked */
185 /* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
186 #define MACRO(...) .macro __VA_ARGS__
189 /* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
194 .equ cfa_current_offset, -8
197 /* ... and .ENDP, replacing ENDP */
203 /* MASM compatible PUBLIC */
209 .macro ASSUME p1 p2 p3 p4 p5 p6 p7 p8
212 /* MASM needs an end tag for segments */
216 /* MASM compatible ALIGN */
219 /* MASM compatible REPEAT, additional ENDR */
223 .macro ljmp segment, offset
224 jmp far ptr \segment:\offset
227 .macro ljmp16 segment, offset
228 jmp far ptr \segment:\offset
231 /* MASM compatible EXTERN */
235 /* MASM needs an END tag */
245 /* check http://msdn.microsoft.com/en-us/library/9c9k076y%28VS.80%29.aspx
246 and http://msdn.microsoft.com/en-us/library/ms679352%28VS.85%29.aspx */
247 .macro FPO cdwLocals, cdwParams, cbProlog, cbRegs, fUseBP, cbFrame
251 /* Macros for x64 stack unwind OPs */
253 .macro .allocstack size
254 .cfi_adjust_cfa_offset \size
255 .set cfa_current_offset, cfa_current_offset - \size
259 .macro .pushframe param=0
261 .cfi_adjust_cfa_offset 0x30
262 .set cfa_current_offset, cfa_current_offset - 0x30
264 .cfi_adjust_cfa_offset 0x28
265 .set cfa_current_offset, cfa_current_offset - 0x28
270 .cfi_adjust_cfa_offset 8
271 .equ cfa_current_offset, cfa_current_offset - 8
272 .cfi_offset \reg, cfa_current_offset
275 .macro .savereg reg, offset
277 .cfi_offset \reg, \offset
280 .macro .savexmm128 reg, offset
282 .cfi_offset \reg, \offset
285 .macro .setframe reg, offset
286 .cfi_def_cfa reg, \offset
287 .equ cfa_current_offset, \offset
293 .macro absolute address
294 __absolute__address__ = \address
297 .macro resb name, size
298 \name = __absolute__address__
299 __absolute__address__ = __absolute__address__ + \size
302 .macro UNIMPLEMENTED2 file, line, func
309 lea rcx, MsgUnimplemented[rip]
316 #define UNIMPLEMENTED UNIMPLEMENTED2 __FILE__, __LINE__,
318 /* MASM/ML uses ".if" for runtime conditionals, and "if" for compile time
319 conditionals. We therefore use "if", too. .if shouldn't be used at all */
323 #define elseif .elseif