[MVDM] Update some of the file headers to their new versions.
[reactos.git] / subsystems / mvdm / dos / asmxtras.inc
1 /*
2 * PROJECT: ReactOS Virtual DOS Machine
3 * LICENSE: GPL-2.0+ (https://spdx.org/licenses/GPL-2.0+)
4 * PURPOSE: Extended ASM macros for GAS and MASM/ML64
5 * COPYRIGHT: Copyright 2015-2018 Hermes Belusca-Maito
6 *
7 * NOTE: This file is an extension to our well-known asm.inc that defines
8 * a set of macros allowing us to assemble specially-crafted ASM files
9 * with both GAS and MASM/ML.
10 *
11 * The additions introduced here are:
12 * - a 'long' define for MASM/ML that aliases to DWORD, and a 'dword'
13 * and 'DWORD' defines for GAS that alias to long.
14 * - an OFF(...) macro that is used for initializing global symbols with
15 * the offset value of another symbol.
16 * - a set of macros for defining and using structures.
17 */
18
19 #ifndef __ASMXTRAS_INC__
20 #define __ASMXTRAS_INC__
21
22 /* 'long' / 'dword'|'DWORD' macros for MASM/ML and GAS */
23 #ifdef _USE_ML
24 #define long dword
25 #else
26 #define dword long
27 #define DWORD long
28 #endif
29
30 /* OFFset macro */
31 #ifdef _USE_ML
32 #define OFF(x) offset x
33 #else
34 #define OFF(x) x
35 #endif
36
37 /*
38 * Set of macros for defining and using structures:
39 * - STRUCT(name, ...) defines a structure of name 'name'.
40 * - FIELD_DECL(field, type, value) adds a new structure member 'field'
41 * of type 'type', with the default value 'value'.
42 * - ENDS(name) terminates the definition of the structure 'name'.
43 * - A symbol 'name' of type 'struct' is declared with VAR_STRUCT(name, struct).
44 * - Referencing a member 'field' of a symbol 'name' is done with FIELD(name, field).
45 */
46 #ifdef _USE_ML
47
48 #define STRUCT(name, ...) \
49 name STRUCT __VA_ARGS__
50
51 #define FIELD_DECL(field, type, value) \
52 field type value
53
54 #define ENDS(name) \
55 name ENDS
56
57 #define VAR_STRUCT(name, struct) \
58 name struct <>
59
60 #define FIELD(name, field) \
61 name##.##field
62
63 #else
64
65 #define STRUCT(name, ...) \
66 MACRO(name, VarName)
67
68 #define FIELD_DECL(field, type, value) \
69 VarName\()_\()field: .type value
70
71 #define ENDS(...) ENDM
72
73 #define VAR_STRUCT(name, struct) \
74 name: struct name
75
76 #define FIELD(name, field) \
77 name##_##field
78
79 #endif
80
81 #endif /* __ASMXTRAS_INC__ */