blob: 7230a71e5d6e44398f3ac89103f6e2952f930175 [file] [log] [blame]
Stefan Reinauer38cd29e2009-08-11 21:28:25 +00001/****************************************************************************
2*
3* Realmode X86 Emulator Library
4*
5* Copyright (C) 1996-1999 SciTech Software, Inc.
6* Copyright (C) David Mosberger-Tang
7* Copyright (C) 1999 Egbert Eich
8*
9* ========================================================================
10*
11* Permission to use, copy, modify, distribute, and sell this software and
12* its documentation for any purpose is hereby granted without fee,
13* provided that the above copyright notice appear in all copies and that
14* both that copyright notice and this permission notice appear in
15* supporting documentation, and that the name of the authors not be used
16* in advertising or publicity pertaining to distribution of the software
17* without specific, written prior permission. The authors makes no
18* representations about the suitability of this software for any purpose.
19* It is provided "as is" without express or implied warranty.
20*
21* THE AUTHORS DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
22* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
23* EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
24* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF
25* USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
26* OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
27* PERFORMANCE OF THIS SOFTWARE.
28*
29* ========================================================================
30*
31* Language: ANSI C
32* Environment: Any
33* Developer: Kendall Bennett
34*
35* Description: Header file for primitive operation functions.
36*
37****************************************************************************/
38
39#ifndef __X86EMU_PRIM_OPS_H
40#define __X86EMU_PRIM_OPS_H
41
42#include "prim_asm.h"
43
44#ifdef __cplusplus
45extern "C" { /* Use "C" linkage when in C++ mode */
46#endif
47
48u16 aaa_word (u16 d);
49u16 aas_word (u16 d);
50u16 aad_word (u16 d);
51u16 aam_word (u8 d);
52u8 adc_byte (u8 d, u8 s);
53u16 adc_word (u16 d, u16 s);
54u32 adc_long (u32 d, u32 s);
55u8 add_byte (u8 d, u8 s);
56u16 add_word (u16 d, u16 s);
57u32 add_long (u32 d, u32 s);
58u8 and_byte (u8 d, u8 s);
59u16 and_word (u16 d, u16 s);
60u32 and_long (u32 d, u32 s);
61u8 cmp_byte (u8 d, u8 s);
62u16 cmp_word (u16 d, u16 s);
63u32 cmp_long (u32 d, u32 s);
64u8 daa_byte (u8 d);
65u8 das_byte (u8 d);
66u8 dec_byte (u8 d);
67u16 dec_word (u16 d);
68u32 dec_long (u32 d);
69u8 inc_byte (u8 d);
70u16 inc_word (u16 d);
71u32 inc_long (u32 d);
72u8 or_byte (u8 d, u8 s);
73u16 or_word (u16 d, u16 s);
74u32 or_long (u32 d, u32 s);
75u8 neg_byte (u8 s);
76u16 neg_word (u16 s);
77u32 neg_long (u32 s);
78u8 not_byte (u8 s);
79u16 not_word (u16 s);
80u32 not_long (u32 s);
81u8 rcl_byte (u8 d, u8 s);
82u16 rcl_word (u16 d, u8 s);
83u32 rcl_long (u32 d, u8 s);
84u8 rcr_byte (u8 d, u8 s);
85u16 rcr_word (u16 d, u8 s);
86u32 rcr_long (u32 d, u8 s);
87u8 rol_byte (u8 d, u8 s);
88u16 rol_word (u16 d, u8 s);
89u32 rol_long (u32 d, u8 s);
90u8 ror_byte (u8 d, u8 s);
91u16 ror_word (u16 d, u8 s);
92u32 ror_long (u32 d, u8 s);
93u8 shl_byte (u8 d, u8 s);
94u16 shl_word (u16 d, u8 s);
95u32 shl_long (u32 d, u8 s);
96u8 shr_byte (u8 d, u8 s);
97u16 shr_word (u16 d, u8 s);
98u32 shr_long (u32 d, u8 s);
99u8 sar_byte (u8 d, u8 s);
100u16 sar_word (u16 d, u8 s);
101u32 sar_long (u32 d, u8 s);
102u16 shld_word (u16 d, u16 fill, u8 s);
103u32 shld_long (u32 d, u32 fill, u8 s);
104u16 shrd_word (u16 d, u16 fill, u8 s);
105u32 shrd_long (u32 d, u32 fill, u8 s);
106u8 sbb_byte (u8 d, u8 s);
107u16 sbb_word (u16 d, u16 s);
108u32 sbb_long (u32 d, u32 s);
109u8 sub_byte (u8 d, u8 s);
110u16 sub_word (u16 d, u16 s);
111u32 sub_long (u32 d, u32 s);
112void test_byte (u8 d, u8 s);
113void test_word (u16 d, u16 s);
114void test_long (u32 d, u32 s);
115u8 xor_byte (u8 d, u8 s);
116u16 xor_word (u16 d, u16 s);
117u32 xor_long (u32 d, u32 s);
118void imul_byte (u8 s);
119void imul_word (u16 s);
120void imul_long (u32 s);
121void imul_long_direct(u32 *res_lo, u32* res_hi,u32 d, u32 s);
122void mul_byte (u8 s);
123void mul_word (u16 s);
124void mul_long (u32 s);
125void idiv_byte (u8 s);
126void idiv_word (u16 s);
127void idiv_long (u32 s);
128void div_byte (u8 s);
129void div_word (u16 s);
130void div_long (u32 s);
131void ins (int size);
132void outs (int size);
133u16 mem_access_word (int addr);
134void push_word (u16 w);
135void push_long (u32 w);
136u16 pop_word (void);
Stefan Reinauer7110d402009-11-03 14:59:43 +0000137u32 pop_long (void);
138void x86emu_cpuid (void);
Stefan Reinauer38cd29e2009-08-11 21:28:25 +0000139
140#if defined(__HAVE_INLINE_ASSEMBLER__) && !defined(PRIM_OPS_NO_REDEFINE_ASM)
141
142#define aaa_word(d) aaa_word_asm(&M.x86.R_EFLG,d)
143#define aas_word(d) aas_word_asm(&M.x86.R_EFLG,d)
144#define aad_word(d) aad_word_asm(&M.x86.R_EFLG,d)
145#define aam_word(d) aam_word_asm(&M.x86.R_EFLG,d)
146#define adc_byte(d,s) adc_byte_asm(&M.x86.R_EFLG,d,s)
147#define adc_word(d,s) adc_word_asm(&M.x86.R_EFLG,d,s)
148#define adc_long(d,s) adc_long_asm(&M.x86.R_EFLG,d,s)
149#define add_byte(d,s) add_byte_asm(&M.x86.R_EFLG,d,s)
150#define add_word(d,s) add_word_asm(&M.x86.R_EFLG,d,s)
151#define add_long(d,s) add_long_asm(&M.x86.R_EFLG,d,s)
152#define and_byte(d,s) and_byte_asm(&M.x86.R_EFLG,d,s)
153#define and_word(d,s) and_word_asm(&M.x86.R_EFLG,d,s)
154#define and_long(d,s) and_long_asm(&M.x86.R_EFLG,d,s)
155#define cmp_byte(d,s) cmp_byte_asm(&M.x86.R_EFLG,d,s)
156#define cmp_word(d,s) cmp_word_asm(&M.x86.R_EFLG,d,s)
157#define cmp_long(d,s) cmp_long_asm(&M.x86.R_EFLG,d,s)
158#define daa_byte(d) daa_byte_asm(&M.x86.R_EFLG,d)
159#define das_byte(d) das_byte_asm(&M.x86.R_EFLG,d)
160#define dec_byte(d) dec_byte_asm(&M.x86.R_EFLG,d)
161#define dec_word(d) dec_word_asm(&M.x86.R_EFLG,d)
162#define dec_long(d) dec_long_asm(&M.x86.R_EFLG,d)
163#define inc_byte(d) inc_byte_asm(&M.x86.R_EFLG,d)
164#define inc_word(d) inc_word_asm(&M.x86.R_EFLG,d)
165#define inc_long(d) inc_long_asm(&M.x86.R_EFLG,d)
166#define or_byte(d,s) or_byte_asm(&M.x86.R_EFLG,d,s)
167#define or_word(d,s) or_word_asm(&M.x86.R_EFLG,d,s)
168#define or_long(d,s) or_long_asm(&M.x86.R_EFLG,d,s)
169#define neg_byte(s) neg_byte_asm(&M.x86.R_EFLG,s)
170#define neg_word(s) neg_word_asm(&M.x86.R_EFLG,s)
171#define neg_long(s) neg_long_asm(&M.x86.R_EFLG,s)
172#define not_byte(s) not_byte_asm(&M.x86.R_EFLG,s)
173#define not_word(s) not_word_asm(&M.x86.R_EFLG,s)
174#define not_long(s) not_long_asm(&M.x86.R_EFLG,s)
175#define rcl_byte(d,s) rcl_byte_asm(&M.x86.R_EFLG,d,s)
176#define rcl_word(d,s) rcl_word_asm(&M.x86.R_EFLG,d,s)
177#define rcl_long(d,s) rcl_long_asm(&M.x86.R_EFLG,d,s)
178#define rcr_byte(d,s) rcr_byte_asm(&M.x86.R_EFLG,d,s)
179#define rcr_word(d,s) rcr_word_asm(&M.x86.R_EFLG,d,s)
180#define rcr_long(d,s) rcr_long_asm(&M.x86.R_EFLG,d,s)
181#define rol_byte(d,s) rol_byte_asm(&M.x86.R_EFLG,d,s)
182#define rol_word(d,s) rol_word_asm(&M.x86.R_EFLG,d,s)
183#define rol_long(d,s) rol_long_asm(&M.x86.R_EFLG,d,s)
184#define ror_byte(d,s) ror_byte_asm(&M.x86.R_EFLG,d,s)
185#define ror_word(d,s) ror_word_asm(&M.x86.R_EFLG,d,s)
186#define ror_long(d,s) ror_long_asm(&M.x86.R_EFLG,d,s)
187#define shl_byte(d,s) shl_byte_asm(&M.x86.R_EFLG,d,s)
188#define shl_word(d,s) shl_word_asm(&M.x86.R_EFLG,d,s)
189#define shl_long(d,s) shl_long_asm(&M.x86.R_EFLG,d,s)
190#define shr_byte(d,s) shr_byte_asm(&M.x86.R_EFLG,d,s)
191#define shr_word(d,s) shr_word_asm(&M.x86.R_EFLG,d,s)
192#define shr_long(d,s) shr_long_asm(&M.x86.R_EFLG,d,s)
193#define sar_byte(d,s) sar_byte_asm(&M.x86.R_EFLG,d,s)
194#define sar_word(d,s) sar_word_asm(&M.x86.R_EFLG,d,s)
195#define sar_long(d,s) sar_long_asm(&M.x86.R_EFLG,d,s)
196#define shld_word(d,fill,s) shld_word_asm(&M.x86.R_EFLG,d,fill,s)
197#define shld_long(d,fill,s) shld_long_asm(&M.x86.R_EFLG,d,fill,s)
198#define shrd_word(d,fill,s) shrd_word_asm(&M.x86.R_EFLG,d,fill,s)
199#define shrd_long(d,fill,s) shrd_long_asm(&M.x86.R_EFLG,d,fill,s)
200#define sbb_byte(d,s) sbb_byte_asm(&M.x86.R_EFLG,d,s)
201#define sbb_word(d,s) sbb_word_asm(&M.x86.R_EFLG,d,s)
202#define sbb_long(d,s) sbb_long_asm(&M.x86.R_EFLG,d,s)
203#define sub_byte(d,s) sub_byte_asm(&M.x86.R_EFLG,d,s)
204#define sub_word(d,s) sub_word_asm(&M.x86.R_EFLG,d,s)
205#define sub_long(d,s) sub_long_asm(&M.x86.R_EFLG,d,s)
206#define test_byte(d,s) test_byte_asm(&M.x86.R_EFLG,d,s)
207#define test_word(d,s) test_word_asm(&M.x86.R_EFLG,d,s)
208#define test_long(d,s) test_long_asm(&M.x86.R_EFLG,d,s)
209#define xor_byte(d,s) xor_byte_asm(&M.x86.R_EFLG,d,s)
210#define xor_word(d,s) xor_word_asm(&M.x86.R_EFLG,d,s)
211#define xor_long(d,s) xor_long_asm(&M.x86.R_EFLG,d,s)
212#define imul_byte(s) imul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s)
213#define imul_word(s) imul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s)
214#define imul_long(s) imul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s)
215#define imul_long_direct(res_lo,res_hi,d,s) imul_long_asm(&M.x86.R_EFLG,res_lo,res_hi,d,s)
216#define mul_byte(s) mul_byte_asm(&M.x86.R_EFLG,&M.x86.R_AX,M.x86.R_AL,s)
217#define mul_word(s) mul_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,s)
218#define mul_long(s) mul_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,s)
219#define idiv_byte(s) idiv_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s)
220#define idiv_word(s) idiv_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s)
221#define idiv_long(s) idiv_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s)
222#define div_byte(s) div_byte_asm(&M.x86.R_EFLG,&M.x86.R_AL,&M.x86.R_AH,M.x86.R_AX,s)
223#define div_word(s) div_word_asm(&M.x86.R_EFLG,&M.x86.R_AX,&M.x86.R_DX,M.x86.R_AX,M.x86.R_DX,s)
224#define div_long(s) div_long_asm(&M.x86.R_EFLG,&M.x86.R_EAX,&M.x86.R_EDX,M.x86.R_EAX,M.x86.R_EDX,s)
225
226#endif
227
228#ifdef __cplusplus
229} /* End of "C" linkage for C++ */
230#endif
231
232#endif /* __X86EMU_PRIM_OPS_H */