2 * i386 execution defines
4 * Copyright (c) 2003 Fabrice Bellard
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 typedef unsigned char uint8_t;
21 typedef unsigned short uint16_t;
22 typedef unsigned int uint32_t;
23 typedef unsigned long long uint64_t;
25 typedef signed char int8_t;
26 typedef signed short int16_t;
27 typedef signed int int32_t;
28 typedef signed long long int64_t;
34 (((uint32_t)(__x) & (uint32_t)0x000000ffUL) << 24) | \
35 (((uint32_t)(__x) & (uint32_t)0x0000ff00UL) << 8) | \
36 (((uint32_t)(__x) & (uint32_t)0x00ff0000UL) >> 8) | \
37 (((uint32_t)(__x) & (uint32_t)0xff000000UL) >> 24) )); \
43 typedef struct FILE FILE;
46 extern int fprintf(FILE *, const char *, ...);
47 extern int printf(const char *, ...);
50 register unsigned int T0 asm("ebx");
51 register unsigned int T1 asm("esi");
52 register unsigned int A0 asm("edi");
53 register struct CPUX86State *env asm("ebp");
56 register unsigned int EAX asm("r16");
57 register unsigned int ECX asm("r17");
58 register unsigned int EDX asm("r18");
59 register unsigned int EBX asm("r19");
60 register unsigned int ESP asm("r20");
61 register unsigned int EBP asm("r21");
62 register unsigned int ESI asm("r22");
63 register unsigned int EDI asm("r23");
64 register unsigned int T0 asm("r24");
65 register unsigned int T1 asm("r25");
66 register unsigned int A0 asm("r26");
67 register struct CPUX86State *env asm("r27");
68 #define USE_INT_TO_FLOAT_HELPERS
69 #define BUGGY_GCC_DIV64
80 register unsigned int T0 asm("r4");
81 register unsigned int T1 asm("r5");
82 register unsigned int A0 asm("r6");
83 register struct CPUX86State *env asm("r7");
86 register unsigned int T0 asm("s0");
87 register unsigned int T1 asm("s1");
88 register unsigned int A0 asm("s2");
89 register struct CPUX86State *env asm("s3");
92 register unsigned int T0 asm("l0");
93 register unsigned int T1 asm("l1");
94 register unsigned int A0 asm("l2");
95 register struct CPUX86State *env asm("l3");
96 #define USE_FP_CONVERT
99 register unsigned int T0 asm("r7");
100 register unsigned int T1 asm("r8");
101 register unsigned int A0 asm("r9");
102 register struct CPUX86State *env asm("r10");
105 register unsigned int T0 asm("$9");
106 register unsigned int T1 asm("$10");
107 register unsigned int A0 asm("$11");
108 register unsigned int EAX asm("$12");
109 register unsigned int ESP asm("$13");
110 register unsigned int EBP asm("$14");
111 register struct CPUX86State *env asm("$15");
117 register unsigned int T0 asm("r24");
118 register unsigned int T1 asm("r25");
119 register unsigned int A0 asm("r26");
120 register struct CPUX86State *env asm("r27");
123 /* force GCC to generate only one epilog at the end of the function */
124 #define FORCE_RET() asm volatile ("");
130 #define xglue(x, y) x ## y
131 #define glue(x, y) xglue(x, y)
134 #define EAX (env->regs[R_EAX])
137 #define ECX (env->regs[R_ECX])
140 #define EDX (env->regs[R_EDX])
143 #define EBX (env->regs[R_EBX])
146 #define ESP (env->regs[R_ESP])
149 #define EBP (env->regs[R_EBP])
152 #define ESI (env->regs[R_ESI])
155 #define EDI (env->regs[R_EDI])
157 #define EIP (env->eip)
160 #define CC_SRC (env->cc_src)
161 #define CC_DST (env->cc_dst)
162 #define CC_OP (env->cc_op)
165 #define FT0 (env->ft0)
166 #define ST0 (env->fpregs[env->fpstt])
167 #define ST(n) (env->fpregs[(env->fpstt + (n)) & 7])
170 #ifdef USE_FP_CONVERT
171 #define FP_CONVERT (env->fp_convert)
175 /* Suggested by Richard Henderson. This will result in code like
176 ldah $0,__op_param1($29) !gprelhigh
177 lda $0,__op_param1($0) !gprellow
178 We can then conveniently change $29 to $31 and adapt the offsets to
179 emit the appropriate constant. */
180 extern int __op_param1 __attribute__((visibility("hidden")));
181 extern int __op_param2 __attribute__((visibility("hidden")));
182 extern int __op_param3 __attribute__((visibility("hidden")));
183 #define PARAM1 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param1)); _r; })
184 #define PARAM2 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param2)); _r; })
185 #define PARAM3 ({ int _r; asm("" : "=r"(_r) : "0" (&__op_param3)); _r; })
187 extern int __op_param1, __op_param2, __op_param3;
188 #define PARAM1 ((long)(&__op_param1))
189 #define PARAM2 ((long)(&__op_param2))
190 #define PARAM3 ((long)(&__op_param3))
193 #include "cpu-i386.h"
195 typedef struct CCTable {
196 int (*compute_all)(void); /* return all the flags */
197 int (*compute_c)(void); /* return the C flag */
200 extern CCTable cc_table[];
202 void load_seg(int seg_reg, int selector);
204 void cpu_unlock(void);
205 void raise_exception_err(int exception_index, int error_code);
206 void raise_exception(int exception_index);
208 void OPPROTO op_movl_eflags_T0(void);
209 void OPPROTO op_movl_T0_eflags(void);