* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS Kernel
* FILE: ntoskrnl/include/amd64/asmmacro.S
- * PURPOSE: ASM macros for for GAS and ML64
+ * PURPOSE: ASM macros for for GAS and MASM/ML64
* PROGRAMMERS: Timo Kreuzer (timo.kreuzer@reactos.org)
*/
#ifdef _MSC_VER
+/* Allow ".name" identifiers */
+OPTION DOTNAME
+
+/* Hex numbers need to be in 01ABh format */
+#define HEX(x) 0##x##h
+
+/* Macro values need to be marked */
+#define VAL(x) x
+
/* MASM/ML doesn't want explicit [rip] addressing */
-#define RIP(address) address
+rip = 0
/* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
#define MACRO(name, ...) name MACRO __VA_ARGS__
name ENDP
ENDM
+/* MASM doesn't have an ASCII macro */
+.ASCII MACRO text
+ DB text
+ENDM
+
+/* MASM doesn't have an ASCIZ macro */
+.ASCIZ MACRO text
+ DB text, 0
+ENDM
+
+/* We need this to distinguish repeat from macros */
+#define ENDR ENDM
#else /***********************************************************************/
.intel_syntax noprefix
.code64
-/* GAS needs explicit [rip] addressing */
-#define RIP(address) address##[rip]
+.altmacro
+
+/* Hex numbers need to be in 0x1AB format */
+#define HEX(x) 0x##x
+
+/* Macro values need to be marked */
+#define VAL(x) \x
/* Due to MASM's reverse syntax, we are forced to use a precompiler macro */
-#define MACRO(name, ...) .MACRO name, __VA_ARGS__
+#define MACRO(...) .macro __VA_ARGS__
+#define ENDM .endm
/* To avoid reverse syntax we provide a new macro .PROC, replacing PROC... */
.macro .PROC name
.endm
/* ... and .ENDP, replacing ENDP */
-.macro .ENDP
+.macro .ENDP name
.cfi_endproc
.endfunc
.endm
/* MASM compatible PUBLIC */
#define PUBLIC .global
+/* MASM compatible ALIGN */
+#define ALIGN .align
+
+/* MASM compatible REPEAT, additional ENDR */
+#define REPEAT .rept
+#define ENDR .endr
+
+/* MASM compatible EXTERN */
+.macro EXTERN name
+.endm
+
+/* MASM needs an END tag */
+#define END
+
/* Macros for x64 stack unwind OPs */
.macro .allocstack size
.set cfa_current_offset, cfa_current_offset - \size
.endm
-.macro .pushframe code
- .if (\code == 0)
- .cfi_adjust_cfa_offset 0x28
- .set cfa_current_offset, cfa_current_offset - 0x28
- .else
+code = 1
+.macro .pushframe param=0
+ .if (\param)
.cfi_adjust_cfa_offset 0x30
.set cfa_current_offset, cfa_current_offset - 0x30
+ .else
+ .cfi_adjust_cfa_offset 0x28
+ .set cfa_current_offset, cfa_current_offset - 0x28
.endif
.endm
.macro .endprolog
.endm
-.macro UNIMPLEMENTED2 file, line, func
+// Note the file1. This is a hack, as "\file" doesn't work with __FILE__, when
+// .altmacro is specified.
+.macro UNIMPLEMENTED2 file1, line, func
+
jmp 3f
- .equ expr, 12
1: .asciz "\func"
2: .asciz "\file"
3:
conditionals. We therefore use "if", too. .if shouldn't be used at all */
#define if .if
#define endif .endif
+#define else .else
#endif