Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
qemu
提交
5dd9488c
Q
qemu
项目概览
openeuler
/
qemu
通知
10
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
Q
qemu
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
5dd9488c
编写于
3月 16, 2003
作者:
B
bellard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
added cmov instruction
git-svn-id:
svn://svn.savannah.nongnu.org/qemu/trunk@32
c046a42c-6fe2-441c-8c8c-71466251a162
上级
60cd49d5
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
125 addition
and
65 deletion
+125
-65
TODO
TODO
+0
-1
opreg_template.h
opreg_template.h
+13
-0
ops_template.h
ops_template.h
+1
-0
tests/test-i386.c
tests/test-i386.c
+68
-46
translate-i386.c
translate-i386.c
+43
-18
未找到文件。
TODO
浏览文件 @
5dd9488c
- segment ops (minimal LDT/GDT support for wine)
- optimize translated cache chaining (DLL PLT like system)
- improved 16 bit support
- optimize inverse flags propagation (easy by generating intermediate
...
...
opreg_template.h
浏览文件 @
5dd9488c
...
...
@@ -60,6 +60,19 @@ void OPPROTO glue(glue(op_movl,REGNAME),_A0)(void)
REG
=
A0
;
}
/* mov T1 to REG if T0 is true */
void
OPPROTO
glue
(
glue
(
op_cmovw
,
REGNAME
),
_T1_T0
)(
void
)
{
if
(
T0
)
REG
=
(
REG
&
0xffff0000
)
|
(
T1
&
0xffff
);
}
void
OPPROTO
glue
(
glue
(
op_cmovl
,
REGNAME
),
_T1_T0
)(
void
)
{
if
(
T0
)
REG
=
T1
;
}
/* NOTE: T0 high order bits are ignored */
void
OPPROTO
glue
(
glue
(
op_movw
,
REGNAME
),
_T0
)(
void
)
{
...
...
ops_template.h
浏览文件 @
5dd9488c
...
...
@@ -385,6 +385,7 @@ void OPPROTO glue(op_setle_T0_sub, SUFFIX)(void)
void
OPPROTO
glue
(
glue
(
op_rol
,
SUFFIX
),
_T0_T1_cc
)(
void
)
{
int
count
,
src
;
/* XXX: testing */
count
=
T1
&
SHIFT_MASK
;
if
(
count
)
{
CC_SRC
=
cc_table
[
CC_OP
].
compute_all
()
&
~
(
CC_O
|
CC_C
);
...
...
tests/test-i386.c
浏览文件 @
5dd9488c
...
...
@@ -3,6 +3,8 @@
#include <inttypes.h>
#include <math.h>
#define TEST_CMOV 0
#define xglue(x, y) x ## y
#define glue(x, y) xglue(x, y)
#define stringify(s) tostring(s)
...
...
@@ -225,79 +227,99 @@ void test_lea(void)
#define TEST_JCC(JCC, v1, v2)\
{\
int res;\
asm("movl $1, %0\n\t"\
"cmpl %2, %1\n\t"\
JCC " 1f\n\t"\
"j"
JCC " 1f\n\t"\
"movl $0, %0\n\t"\
"1:\n\t"\
: "=r" (res)\
: "r" (v1), "r" (v2));\
printf("%-10s %d\n", JCC, res);\
printf("%-10s %d\n", "j" JCC, res);\
\
asm("movl $0, %0\n\t"\
"cmpl %2, %1\n\t"\
"set" JCC " %b0\n\t"\
: "=r" (res)\
: "r" (v1), "r" (v2));\
printf("%-10s %d\n", "set" JCC, res);\
if (TEST_CMOV) {\
asm("movl $0x12345678, %0\n\t"\
"cmpl %2, %1\n\t"\
"cmov" JCC "l %3, %0\n\t"\
: "=r" (res)\
: "r" (v1), "r" (v2), "m" (1));\
printf("%-10s R=0x%08x\n", "cmov" JCC "l", res);\
asm("movl $0x12345678, %0\n\t"\
"cmpl %2, %1\n\t"\
"cmov" JCC "w %w3, %w0\n\t"\
: "=r" (res)\
: "r" (v1), "r" (v2), "r" (1));\
printf("%-10s R=0x%08x\n", "cmov" JCC "w", res);\
} \
}
/* various jump tests */
void
test_jcc
(
void
)
{
int
res
;
TEST_JCC
(
"jne"
,
1
,
1
);
TEST_JCC
(
"jne"
,
1
,
0
);
TEST_JCC
(
"ne"
,
1
,
1
);
TEST_JCC
(
"ne"
,
1
,
0
);
TEST_JCC
(
"
j
e"
,
1
,
1
);
TEST_JCC
(
"
j
e"
,
1
,
0
);
TEST_JCC
(
"e"
,
1
,
1
);
TEST_JCC
(
"e"
,
1
,
0
);
TEST_JCC
(
"
j
l"
,
1
,
1
);
TEST_JCC
(
"
j
l"
,
1
,
0
);
TEST_JCC
(
"
j
l"
,
1
,
-
1
);
TEST_JCC
(
"l"
,
1
,
1
);
TEST_JCC
(
"l"
,
1
,
0
);
TEST_JCC
(
"l"
,
1
,
-
1
);
TEST_JCC
(
"
j
le"
,
1
,
1
);
TEST_JCC
(
"
j
le"
,
1
,
0
);
TEST_JCC
(
"
j
le"
,
1
,
-
1
);
TEST_JCC
(
"le"
,
1
,
1
);
TEST_JCC
(
"le"
,
1
,
0
);
TEST_JCC
(
"le"
,
1
,
-
1
);
TEST_JCC
(
"
j
ge"
,
1
,
1
);
TEST_JCC
(
"
j
ge"
,
1
,
0
);
TEST_JCC
(
"
j
ge"
,
-
1
,
1
);
TEST_JCC
(
"ge"
,
1
,
1
);
TEST_JCC
(
"ge"
,
1
,
0
);
TEST_JCC
(
"ge"
,
-
1
,
1
);
TEST_JCC
(
"
j
g"
,
1
,
1
);
TEST_JCC
(
"
j
g"
,
1
,
0
);
TEST_JCC
(
"
j
g"
,
1
,
-
1
);
TEST_JCC
(
"g"
,
1
,
1
);
TEST_JCC
(
"g"
,
1
,
0
);
TEST_JCC
(
"g"
,
1
,
-
1
);
TEST_JCC
(
"
j
b"
,
1
,
1
);
TEST_JCC
(
"
j
b"
,
1
,
0
);
TEST_JCC
(
"
j
b"
,
1
,
-
1
);
TEST_JCC
(
"b"
,
1
,
1
);
TEST_JCC
(
"b"
,
1
,
0
);
TEST_JCC
(
"b"
,
1
,
-
1
);
TEST_JCC
(
"
j
be"
,
1
,
1
);
TEST_JCC
(
"
j
be"
,
1
,
0
);
TEST_JCC
(
"
j
be"
,
1
,
-
1
);
TEST_JCC
(
"be"
,
1
,
1
);
TEST_JCC
(
"be"
,
1
,
0
);
TEST_JCC
(
"be"
,
1
,
-
1
);
TEST_JCC
(
"
j
ae"
,
1
,
1
);
TEST_JCC
(
"
j
ae"
,
1
,
0
);
TEST_JCC
(
"
j
ae"
,
1
,
-
1
);
TEST_JCC
(
"ae"
,
1
,
1
);
TEST_JCC
(
"ae"
,
1
,
0
);
TEST_JCC
(
"ae"
,
1
,
-
1
);
TEST_JCC
(
"
j
a"
,
1
,
1
);
TEST_JCC
(
"
j
a"
,
1
,
0
);
TEST_JCC
(
"
j
a"
,
1
,
-
1
);
TEST_JCC
(
"a"
,
1
,
1
);
TEST_JCC
(
"a"
,
1
,
0
);
TEST_JCC
(
"a"
,
1
,
-
1
);
TEST_JCC
(
"
j
p"
,
1
,
1
);
TEST_JCC
(
"
j
p"
,
1
,
0
);
TEST_JCC
(
"p"
,
1
,
1
);
TEST_JCC
(
"p"
,
1
,
0
);
TEST_JCC
(
"
j
np"
,
1
,
1
);
TEST_JCC
(
"
j
np"
,
1
,
0
);
TEST_JCC
(
"np"
,
1
,
1
);
TEST_JCC
(
"np"
,
1
,
0
);
TEST_JCC
(
"
j
o"
,
0x7fffffff
,
0
);
TEST_JCC
(
"
j
o"
,
0x7fffffff
,
-
1
);
TEST_JCC
(
"o"
,
0x7fffffff
,
0
);
TEST_JCC
(
"o"
,
0x7fffffff
,
-
1
);
TEST_JCC
(
"
j
no"
,
0x7fffffff
,
0
);
TEST_JCC
(
"
j
no"
,
0x7fffffff
,
-
1
);
TEST_JCC
(
"no"
,
0x7fffffff
,
0
);
TEST_JCC
(
"no"
,
0x7fffffff
,
-
1
);
TEST_JCC
(
"
j
s"
,
0
,
1
);
TEST_JCC
(
"
j
s"
,
0
,
-
1
);
TEST_JCC
(
"
j
s"
,
0
,
0
);
TEST_JCC
(
"s"
,
0
,
1
);
TEST_JCC
(
"s"
,
0
,
-
1
);
TEST_JCC
(
"s"
,
0
,
0
);
TEST_JCC
(
"
j
ns"
,
0
,
1
);
TEST_JCC
(
"
j
ns"
,
0
,
-
1
);
TEST_JCC
(
"
j
ns"
,
0
,
0
);
TEST_JCC
(
"ns"
,
0
,
1
);
TEST_JCC
(
"ns"
,
0
,
-
1
);
TEST_JCC
(
"ns"
,
0
,
0
);
}
#undef CC_MASK
...
...
translate-i386.c
浏览文件 @
5dd9488c
...
...
@@ -44,19 +44,6 @@ int __op_param1, __op_param2, __op_param3;
extern
FILE
*
logfile
;
extern
int
loglevel
;
/* supress that */
static
void
error
(
const
char
*
fmt
,
...)
{
va_list
ap
;
va_start
(
ap
,
fmt
);
fprintf
(
stderr
,
"
\n
"
);
vfprintf
(
stderr
,
fmt
,
ap
);
fprintf
(
stderr
,
"
\n
"
);
va_end
(
ap
);
exit
(
1
);
}
#define PREFIX_REPZ 1
#define PREFIX_REPNZ 2
#define PREFIX_LOCK 4
...
...
@@ -352,6 +339,29 @@ static GenOpFunc *gen_op_addl_A0_reg_sN[4][8] = {
},
};
static
GenOpFunc
*
gen_op_cmov_reg_T1_T0
[
2
][
8
]
=
{
[
0
]
=
{
gen_op_cmovw_EAX_T1_T0
,
gen_op_cmovw_ECX_T1_T0
,
gen_op_cmovw_EDX_T1_T0
,
gen_op_cmovw_EBX_T1_T0
,
gen_op_cmovw_ESP_T1_T0
,
gen_op_cmovw_EBP_T1_T0
,
gen_op_cmovw_ESI_T1_T0
,
gen_op_cmovw_EDI_T1_T0
,
},
[
1
]
=
{
gen_op_cmovl_EAX_T1_T0
,
gen_op_cmovl_ECX_T1_T0
,
gen_op_cmovl_EDX_T1_T0
,
gen_op_cmovl_EBX_T1_T0
,
gen_op_cmovl_ESP_T1_T0
,
gen_op_cmovl_EBP_T1_T0
,
gen_op_cmovl_ESI_T1_T0
,
gen_op_cmovl_EDI_T1_T0
,
},
};
static
GenOpFunc
*
gen_op_arith_T0_T1_cc
[
8
]
=
{
gen_op_addl_T0_T1_cc
,
gen_op_orl_T0_T1_cc
,
...
...
@@ -2586,12 +2596,27 @@ long disas_insn(DisasContext *s, uint8_t *pc_start)
s
->
is_jmp
=
1
;
break
;
case
0x190
...
0x19f
:
case
0x190
...
0x19f
:
/* setcc Gv */
modrm
=
ldub
(
s
->
pc
++
);
gen_setcc
(
s
,
b
);
gen_ldst_modrm
(
s
,
modrm
,
OT_BYTE
,
OR_TMP0
,
1
);
break
;
case
0x140
...
0x14f
:
/* cmov Gv, Ev */
ot
=
dflag
?
OT_LONG
:
OT_WORD
;
modrm
=
ldub
(
s
->
pc
++
);
reg
=
(
modrm
>>
3
)
&
7
;
mod
=
(
modrm
>>
6
)
&
3
;
gen_setcc
(
s
,
b
);
if
(
mod
!=
3
)
{
gen_lea_modrm
(
s
,
modrm
,
&
reg_addr
,
&
offset_addr
);
gen_op_ld_T1_A0
[
ot
]();
}
else
{
rm
=
modrm
&
7
;
gen_op_mov_TN_reg
[
ot
][
1
][
rm
]();
}
gen_op_cmov_reg_T1_T0
[
ot
-
OT_WORD
][
reg
]();
break
;
/************************/
/* flags */
case
0x9c
:
/* pushf */
...
...
@@ -2801,7 +2826,7 @@ long disas_insn(DisasContext *s, uint8_t *pc_start)
gen_op_loop
[
s
->
aflag
][
b
&
3
](
val
,
(
long
)
s
->
pc
);
s
->
is_jmp
=
1
;
break
;
case
0x1
a2
:
/* rdtsc */
case
0x1
31
:
/* rdtsc */
gen_op_rdtsc
();
break
;
#if 0
...
...
@@ -2841,8 +2866,8 @@ int cpu_x86_gen_code(uint8_t *gen_code_buf, int max_code_size,
do
{
ret
=
disas_insn
(
dc
,
pc_ptr
);
if
(
ret
==
-
1
)
{
error
(
"unknown instruction at PC=0x%
x B=%02x %02x %02x"
,
pc_ptr
,
pc_ptr
[
0
],
pc_ptr
[
1
],
pc_ptr
[
2
]);
fprintf
(
stderr
,
"unknown instruction at PC=0x%08l
x B=%02x %02x %02x"
,
(
long
)
pc_ptr
,
pc_ptr
[
0
],
pc_ptr
[
1
],
pc_ptr
[
2
]);
abort
();
}
pc_ptr
=
(
void
*
)
ret
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录