RTEMS  5.0.0-m2006-1
asm.h
Go to the documentation of this file.
1 
16 /*
17  * COPYRIGHT:
18  *
19  * This file is based on similar code found in newlib available
20  * from ftp.cygnus.com. The file which was used had no copyright
21  * notice. This file is freely distributable as long as the source
22  * of the file is noted. This file is:
23  *
24  * COPYRIGHT (c) 2018.
25  * Amaan Cheval <amaan.cheval@gmail.com>
26  *
27  * COPYRIGHT (c) 1994-2006.
28  * On-Line Applications Research Corporation (OAR).
29  */
30 
31 #ifndef _RTEMS_ASM_H
32 #define _RTEMS_ASM_H
33 
34 /*
35  * Indicate we are in an assembly file and get the basic CPU definitions.
36  */
37 
38 #ifndef ASM
39 #define ASM
40 #endif
41 #include <rtems/score/cpuopts.h>
42 #include <rtems/score/x86_64.h>
43 
54 #ifndef __USER_LABEL_PREFIX__
55 
63 #define __USER_LABEL_PREFIX__ _
64 #endif
65 
66 #undef __REGISTER_PREFIX__
67 #define __REGISTER_PREFIX__ %
68 
69 #include <rtems/concat.h>
70 
72 #define SYM(x) CONCAT1 (__USER_LABEL_PREFIX__, x)
73 
75 #define REG(x) CONCAT1 (__REGISTER_PREFIX__, x)
76 
77 /*
78  * define macros for all of the registers on this CPU
79  */
80 #define rax REG (rax)
81 #define rbx REG (rbx)
82 #define rcx REG (rcx)
83 #define rdx REG (rdx)
84 #define rdi REG (rdi)
85 #define rsi REG (rsi)
86 #define rbp REG (rbp)
87 #define rsp REG (rsp)
88 #define r8 REG (r8)
89 #define r9 REG (r9)
90 #define r10 REG (r10)
91 #define r11 REG (r11)
92 #define r12 REG (r12)
93 #define r13 REG (r13)
94 #define r14 REG (r14)
95 #define r15 REG (r15)
96 
97 /*
98  * Order of register usage for function arguments as per the calling convention
99  */
100 #define REG_ARG0 rdi
101 #define REG_ARG1 rsi
102 #define REG_ARG2 rdx
103 #define REG_ARG3 rcx
104 #define REG_ARG4 r8
105 #define REG_ARG5 r9
106 
107 // XXX: eax, ax, etc., segment registers
108 
109 /*
110  * Define macros to handle section beginning and ends.
111  */
112 
114 #define BEGIN_CODE_DCL .text
115 
116 #define END_CODE_DCL
117 
118 #define BEGIN_DATA_DCL .data
119 
120 #define END_DATA_DCL
121 
122 #define BEGIN_CODE .text
123 
124 #define END_CODE
125 
126 #define BEGIN_DATA
127 
128 #define END_DATA
129 
132 #define BEGIN_BSS
133 
134 #define END_BSS
135 
136 #define END
137 
144 #define PUBLIC(sym) .globl SYM (sym)
145 
152 #define EXTERN(sym) .globl SYM (sym)
153 
154 #endif
155