aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-09-17 22:52:47 +0000
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>2003-09-17 22:52:47 +0000
commitf513a41a3db60c27c25147730e3a2bd6290bf622 (patch)
tree2dcbbd004c3a4129ee7a113bb9d6073494c77376
parentc106152d26a68e86400d454c86b1e908ba3f77d8 (diff)
finished simplifying string operations
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@379 c046a42c-6fe2-441c-8c8c-71466251a162
-rw-r--r--op-i386.c13
-rw-r--r--op_string.h94
-rw-r--r--ops_template.h71
3 files changed, 52 insertions, 126 deletions
diff --git a/op-i386.c b/op-i386.c
index 2f84e15e54..16521c93ba 100644
--- a/op-i386.c
+++ b/op-i386.c
@@ -516,9 +516,9 @@ void OPPROTO op_cmpxchg8b(void)
helper_cmpxchg8b();
}
-void OPPROTO op_jmp_tb_next(void)
+void OPPROTO op_jmp(void)
{
- JUMP_TB(op_jmp_tb_next, PARAM1, 0, PARAM2);
+ JUMP_TB(op_jmp, PARAM1, 0, PARAM2);
}
void OPPROTO op_movl_T0_0(void)
@@ -1033,6 +1033,15 @@ void OPPROTO op_jcc(void)
FORCE_RET();
}
+void OPPROTO op_jcc_im(void)
+{
+ if (T0)
+ EIP = PARAM1;
+ else
+ EIP = PARAM2;
+ FORCE_RET();
+}
+
/* slow set cases (compute x86 flags) */
void OPPROTO op_seto_T0_cc(void)
{
diff --git a/op_string.h b/op_string.h
deleted file mode 100644
index 66b598b23a..0000000000
--- a/op_string.h
+++ /dev/null
@@ -1,94 +0,0 @@
-
-void OPPROTO glue(glue(op_repz_scas, SUFFIX), STRING_SUFFIX)(void)
-{
- int v1, v2, inc;
-
- if (CX != 0) {
- /* NOTE: the flags are not modified if CX == 0 */
- v1 = EAX & DATA_MASK;
- inc = (DF << SHIFT);
- do {
- v2 = glue(ldu, SUFFIX)(DI_ADDR);
- INC_DI();
- DEC_CX();
- if (v1 != v2)
- break;
- } while (CX != 0);
- CC_SRC = v2;
- CC_DST = v1 - v2;
- CC_OP = CC_OP_SUBB + SHIFT;
- }
- FORCE_RET();
-}
-
-void OPPROTO glue(glue(op_repnz_scas, SUFFIX), STRING_SUFFIX)(void)
-{
- int v1, v2, inc;
-
- if (CX != 0) {
- /* NOTE: the flags are not modified if CX == 0 */
- v1 = EAX & DATA_MASK;
- inc = (DF << SHIFT);
- do {
- v2 = glue(ldu, SUFFIX)(DI_ADDR);
- INC_DI();
- DEC_CX();
- if (v1 == v2)
- break;
- } while (CX != 0);
- CC_SRC = v2;
- CC_DST = v1 - v2;
- CC_OP = CC_OP_SUBB + SHIFT;
- }
- FORCE_RET();
-}
-
-void OPPROTO glue(glue(op_repz_cmps, SUFFIX), STRING_SUFFIX)(void)
-{
- int v1, v2, inc;
- if (CX != 0) {
- inc = (DF << SHIFT);
- do {
- v1 = glue(ldu, SUFFIX)(SI_ADDR);
- v2 = glue(ldu, SUFFIX)(DI_ADDR);
- INC_SI();
- INC_DI();
- DEC_CX();
- if (v1 != v2)
- break;
- } while (CX != 0);
- CC_SRC = v2;
- CC_DST = v1 - v2;
- CC_OP = CC_OP_SUBB + SHIFT;
- }
- FORCE_RET();
-}
-
-void OPPROTO glue(glue(op_repnz_cmps, SUFFIX), STRING_SUFFIX)(void)
-{
- int v1, v2, inc;
- if (CX != 0) {
- inc = (DF << SHIFT);
- do {
- v1 = glue(ldu, SUFFIX)(SI_ADDR);
- v2 = glue(ldu, SUFFIX)(DI_ADDR);
- INC_SI();
- INC_DI();
- DEC_CX();
- if (v1 == v2)
- break;
- } while (CX != 0);
- CC_SRC = v2;
- CC_DST = v1 - v2;
- CC_OP = CC_OP_SUBB + SHIFT;
- }
- FORCE_RET();
-}
-
-#undef STRING_SUFFIX
-#undef SI_ADDR
-#undef DI_ADDR
-#undef INC_SI
-#undef INC_DI
-#undef CX
-#undef DEC_CX
diff --git a/ops_template.h b/ops_template.h
index b55ccf9dbb..182296743b 100644
--- a/ops_template.h
+++ b/ops_template.h
@@ -518,34 +518,6 @@ void OPPROTO op_update_bt_cc(void)
#endif
/* string operations */
-/* XXX: maybe use lower level instructions to ease 16 bit / segment handling */
-
-#define STRING_SUFFIX _fast
-#define SI_ADDR (void *)ESI
-#define DI_ADDR (void *)EDI
-#define INC_SI() ESI += inc
-#define INC_DI() EDI += inc
-#define CX ECX
-#define DEC_CX() ECX--
-#include "op_string.h"
-
-#define STRING_SUFFIX _a32
-#define SI_ADDR (uint8_t *)A0 + ESI
-#define DI_ADDR env->segs[R_ES].base + EDI
-#define INC_SI() ESI += inc
-#define INC_DI() EDI += inc
-#define CX ECX
-#define DEC_CX() ECX--
-#include "op_string.h"
-
-#define STRING_SUFFIX _a16
-#define SI_ADDR (uint8_t *)A0 + (ESI & 0xffff)
-#define DI_ADDR env->segs[R_ES].base + (EDI & 0xffff)
-#define INC_SI() ESI = (ESI & ~0xffff) | ((ESI + inc) & 0xffff)
-#define INC_DI() EDI = (EDI & ~0xffff) | ((EDI + inc) & 0xffff)
-#define CX (ECX & 0xffff)
-#define DEC_CX() ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff)
-#include "op_string.h"
void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void)
{
@@ -555,14 +527,40 @@ void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void)
void OPPROTO glue(op_string_jz_sub, SUFFIX)(void)
{
if ((DATA_TYPE)CC_DST == 0)
- JUMP_TB(glue(op_string_jz_sub, SUFFIX), PARAM1, 1, PARAM2);
+ JUMP_TB2(glue(op_string_jz_sub, SUFFIX), PARAM1, 1);
FORCE_RET();
}
void OPPROTO glue(op_string_jnz_sub, SUFFIX)(void)
{
if ((DATA_TYPE)CC_DST != 0)
- JUMP_TB(glue(op_string_jnz_sub, SUFFIX), PARAM1, 1, PARAM2);
+ JUMP_TB2(glue(op_string_jnz_sub, SUFFIX), PARAM1, 1);
+ FORCE_RET();
+}
+
+void OPPROTO glue(glue(op_string_jz_sub, SUFFIX), _im)(void)
+{
+ if ((DATA_TYPE)CC_DST == 0) {
+ EIP = PARAM1;
+ if (env->eflags & TF_MASK) {
+ raise_exception(EXCP01_SSTP);
+ }
+ T0 = 0;
+ EXIT_TB();
+ }
+ FORCE_RET();
+}
+
+void OPPROTO glue(glue(op_string_jnz_sub, SUFFIX), _im)(void)
+{
+ if ((DATA_TYPE)CC_DST != 0) {
+ EIP = PARAM1;
+ if (env->eflags & TF_MASK) {
+ raise_exception(EXCP01_SSTP);
+ }
+ T0 = 0;
+ EXIT_TB();
+ }
FORCE_RET();
}
@@ -573,6 +571,19 @@ void OPPROTO glue(op_jz_ecx, SUFFIX)(void)
JUMP_TB(glue(op_jz_ecx, SUFFIX), PARAM1, 1, PARAM2);
FORCE_RET();
}
+
+void OPPROTO glue(glue(op_jz_ecx, SUFFIX), _im)(void)
+{
+ if ((DATA_TYPE)ECX == 0) {
+ EIP = PARAM1;
+ if (env->eflags & TF_MASK) {
+ raise_exception(EXCP01_SSTP);
+ }
+ T0 = 0;
+ EXIT_TB();
+ }
+ FORCE_RET();
+}
#endif
/* port I/O */