Commit f513a41a3db60c27c25147730e3a2bd6290bf622
1 parent
c106152d
finished simplifying string operations
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@379 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
3 changed files
with
52 additions
and
126 deletions
op-i386.c
@@ -516,9 +516,9 @@ void OPPROTO op_cmpxchg8b(void) | @@ -516,9 +516,9 @@ void OPPROTO op_cmpxchg8b(void) | ||
516 | helper_cmpxchg8b(); | 516 | helper_cmpxchg8b(); |
517 | } | 517 | } |
518 | 518 | ||
519 | -void OPPROTO op_jmp_tb_next(void) | 519 | +void OPPROTO op_jmp(void) |
520 | { | 520 | { |
521 | - JUMP_TB(op_jmp_tb_next, PARAM1, 0, PARAM2); | 521 | + JUMP_TB(op_jmp, PARAM1, 0, PARAM2); |
522 | } | 522 | } |
523 | 523 | ||
524 | void OPPROTO op_movl_T0_0(void) | 524 | void OPPROTO op_movl_T0_0(void) |
@@ -1033,6 +1033,15 @@ void OPPROTO op_jcc(void) | @@ -1033,6 +1033,15 @@ void OPPROTO op_jcc(void) | ||
1033 | FORCE_RET(); | 1033 | FORCE_RET(); |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | +void OPPROTO op_jcc_im(void) | ||
1037 | +{ | ||
1038 | + if (T0) | ||
1039 | + EIP = PARAM1; | ||
1040 | + else | ||
1041 | + EIP = PARAM2; | ||
1042 | + FORCE_RET(); | ||
1043 | +} | ||
1044 | + | ||
1036 | /* slow set cases (compute x86 flags) */ | 1045 | /* slow set cases (compute x86 flags) */ |
1037 | void OPPROTO op_seto_T0_cc(void) | 1046 | void OPPROTO op_seto_T0_cc(void) |
1038 | { | 1047 | { |
op_string.h deleted
100644 → 0
1 | - | ||
2 | -void OPPROTO glue(glue(op_repz_scas, SUFFIX), STRING_SUFFIX)(void) | ||
3 | -{ | ||
4 | - int v1, v2, inc; | ||
5 | - | ||
6 | - if (CX != 0) { | ||
7 | - /* NOTE: the flags are not modified if CX == 0 */ | ||
8 | - v1 = EAX & DATA_MASK; | ||
9 | - inc = (DF << SHIFT); | ||
10 | - do { | ||
11 | - v2 = glue(ldu, SUFFIX)(DI_ADDR); | ||
12 | - INC_DI(); | ||
13 | - DEC_CX(); | ||
14 | - if (v1 != v2) | ||
15 | - break; | ||
16 | - } while (CX != 0); | ||
17 | - CC_SRC = v2; | ||
18 | - CC_DST = v1 - v2; | ||
19 | - CC_OP = CC_OP_SUBB + SHIFT; | ||
20 | - } | ||
21 | - FORCE_RET(); | ||
22 | -} | ||
23 | - | ||
24 | -void OPPROTO glue(glue(op_repnz_scas, SUFFIX), STRING_SUFFIX)(void) | ||
25 | -{ | ||
26 | - int v1, v2, inc; | ||
27 | - | ||
28 | - if (CX != 0) { | ||
29 | - /* NOTE: the flags are not modified if CX == 0 */ | ||
30 | - v1 = EAX & DATA_MASK; | ||
31 | - inc = (DF << SHIFT); | ||
32 | - do { | ||
33 | - v2 = glue(ldu, SUFFIX)(DI_ADDR); | ||
34 | - INC_DI(); | ||
35 | - DEC_CX(); | ||
36 | - if (v1 == v2) | ||
37 | - break; | ||
38 | - } while (CX != 0); | ||
39 | - CC_SRC = v2; | ||
40 | - CC_DST = v1 - v2; | ||
41 | - CC_OP = CC_OP_SUBB + SHIFT; | ||
42 | - } | ||
43 | - FORCE_RET(); | ||
44 | -} | ||
45 | - | ||
46 | -void OPPROTO glue(glue(op_repz_cmps, SUFFIX), STRING_SUFFIX)(void) | ||
47 | -{ | ||
48 | - int v1, v2, inc; | ||
49 | - if (CX != 0) { | ||
50 | - inc = (DF << SHIFT); | ||
51 | - do { | ||
52 | - v1 = glue(ldu, SUFFIX)(SI_ADDR); | ||
53 | - v2 = glue(ldu, SUFFIX)(DI_ADDR); | ||
54 | - INC_SI(); | ||
55 | - INC_DI(); | ||
56 | - DEC_CX(); | ||
57 | - if (v1 != v2) | ||
58 | - break; | ||
59 | - } while (CX != 0); | ||
60 | - CC_SRC = v2; | ||
61 | - CC_DST = v1 - v2; | ||
62 | - CC_OP = CC_OP_SUBB + SHIFT; | ||
63 | - } | ||
64 | - FORCE_RET(); | ||
65 | -} | ||
66 | - | ||
67 | -void OPPROTO glue(glue(op_repnz_cmps, SUFFIX), STRING_SUFFIX)(void) | ||
68 | -{ | ||
69 | - int v1, v2, inc; | ||
70 | - if (CX != 0) { | ||
71 | - inc = (DF << SHIFT); | ||
72 | - do { | ||
73 | - v1 = glue(ldu, SUFFIX)(SI_ADDR); | ||
74 | - v2 = glue(ldu, SUFFIX)(DI_ADDR); | ||
75 | - INC_SI(); | ||
76 | - INC_DI(); | ||
77 | - DEC_CX(); | ||
78 | - if (v1 == v2) | ||
79 | - break; | ||
80 | - } while (CX != 0); | ||
81 | - CC_SRC = v2; | ||
82 | - CC_DST = v1 - v2; | ||
83 | - CC_OP = CC_OP_SUBB + SHIFT; | ||
84 | - } | ||
85 | - FORCE_RET(); | ||
86 | -} | ||
87 | - | ||
88 | -#undef STRING_SUFFIX | ||
89 | -#undef SI_ADDR | ||
90 | -#undef DI_ADDR | ||
91 | -#undef INC_SI | ||
92 | -#undef INC_DI | ||
93 | -#undef CX | ||
94 | -#undef DEC_CX |
ops_template.h
@@ -518,34 +518,6 @@ void OPPROTO op_update_bt_cc(void) | @@ -518,34 +518,6 @@ void OPPROTO op_update_bt_cc(void) | ||
518 | #endif | 518 | #endif |
519 | 519 | ||
520 | /* string operations */ | 520 | /* string operations */ |
521 | -/* XXX: maybe use lower level instructions to ease 16 bit / segment handling */ | ||
522 | - | ||
523 | -#define STRING_SUFFIX _fast | ||
524 | -#define SI_ADDR (void *)ESI | ||
525 | -#define DI_ADDR (void *)EDI | ||
526 | -#define INC_SI() ESI += inc | ||
527 | -#define INC_DI() EDI += inc | ||
528 | -#define CX ECX | ||
529 | -#define DEC_CX() ECX-- | ||
530 | -#include "op_string.h" | ||
531 | - | ||
532 | -#define STRING_SUFFIX _a32 | ||
533 | -#define SI_ADDR (uint8_t *)A0 + ESI | ||
534 | -#define DI_ADDR env->segs[R_ES].base + EDI | ||
535 | -#define INC_SI() ESI += inc | ||
536 | -#define INC_DI() EDI += inc | ||
537 | -#define CX ECX | ||
538 | -#define DEC_CX() ECX-- | ||
539 | -#include "op_string.h" | ||
540 | - | ||
541 | -#define STRING_SUFFIX _a16 | ||
542 | -#define SI_ADDR (uint8_t *)A0 + (ESI & 0xffff) | ||
543 | -#define DI_ADDR env->segs[R_ES].base + (EDI & 0xffff) | ||
544 | -#define INC_SI() ESI = (ESI & ~0xffff) | ((ESI + inc) & 0xffff) | ||
545 | -#define INC_DI() EDI = (EDI & ~0xffff) | ((EDI + inc) & 0xffff) | ||
546 | -#define CX (ECX & 0xffff) | ||
547 | -#define DEC_CX() ECX = (ECX & ~0xffff) | ((ECX - 1) & 0xffff) | ||
548 | -#include "op_string.h" | ||
549 | 521 | ||
550 | void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void) | 522 | void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void) |
551 | { | 523 | { |
@@ -555,14 +527,40 @@ void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void) | @@ -555,14 +527,40 @@ void OPPROTO glue(op_movl_T0_Dshift, SUFFIX)(void) | ||
555 | void OPPROTO glue(op_string_jz_sub, SUFFIX)(void) | 527 | void OPPROTO glue(op_string_jz_sub, SUFFIX)(void) |
556 | { | 528 | { |
557 | if ((DATA_TYPE)CC_DST == 0) | 529 | if ((DATA_TYPE)CC_DST == 0) |
558 | - JUMP_TB(glue(op_string_jz_sub, SUFFIX), PARAM1, 1, PARAM2); | 530 | + JUMP_TB2(glue(op_string_jz_sub, SUFFIX), PARAM1, 1); |
559 | FORCE_RET(); | 531 | FORCE_RET(); |
560 | } | 532 | } |
561 | 533 | ||
562 | void OPPROTO glue(op_string_jnz_sub, SUFFIX)(void) | 534 | void OPPROTO glue(op_string_jnz_sub, SUFFIX)(void) |
563 | { | 535 | { |
564 | if ((DATA_TYPE)CC_DST != 0) | 536 | if ((DATA_TYPE)CC_DST != 0) |
565 | - JUMP_TB(glue(op_string_jnz_sub, SUFFIX), PARAM1, 1, PARAM2); | 537 | + JUMP_TB2(glue(op_string_jnz_sub, SUFFIX), PARAM1, 1); |
538 | + FORCE_RET(); | ||
539 | +} | ||
540 | + | ||
541 | +void OPPROTO glue(glue(op_string_jz_sub, SUFFIX), _im)(void) | ||
542 | +{ | ||
543 | + if ((DATA_TYPE)CC_DST == 0) { | ||
544 | + EIP = PARAM1; | ||
545 | + if (env->eflags & TF_MASK) { | ||
546 | + raise_exception(EXCP01_SSTP); | ||
547 | + } | ||
548 | + T0 = 0; | ||
549 | + EXIT_TB(); | ||
550 | + } | ||
551 | + FORCE_RET(); | ||
552 | +} | ||
553 | + | ||
554 | +void OPPROTO glue(glue(op_string_jnz_sub, SUFFIX), _im)(void) | ||
555 | +{ | ||
556 | + if ((DATA_TYPE)CC_DST != 0) { | ||
557 | + EIP = PARAM1; | ||
558 | + if (env->eflags & TF_MASK) { | ||
559 | + raise_exception(EXCP01_SSTP); | ||
560 | + } | ||
561 | + T0 = 0; | ||
562 | + EXIT_TB(); | ||
563 | + } | ||
566 | FORCE_RET(); | 564 | FORCE_RET(); |
567 | } | 565 | } |
568 | 566 | ||
@@ -573,6 +571,19 @@ void OPPROTO glue(op_jz_ecx, SUFFIX)(void) | @@ -573,6 +571,19 @@ void OPPROTO glue(op_jz_ecx, SUFFIX)(void) | ||
573 | JUMP_TB(glue(op_jz_ecx, SUFFIX), PARAM1, 1, PARAM2); | 571 | JUMP_TB(glue(op_jz_ecx, SUFFIX), PARAM1, 1, PARAM2); |
574 | FORCE_RET(); | 572 | FORCE_RET(); |
575 | } | 573 | } |
574 | + | ||
575 | +void OPPROTO glue(glue(op_jz_ecx, SUFFIX), _im)(void) | ||
576 | +{ | ||
577 | + if ((DATA_TYPE)ECX == 0) { | ||
578 | + EIP = PARAM1; | ||
579 | + if (env->eflags & TF_MASK) { | ||
580 | + raise_exception(EXCP01_SSTP); | ||
581 | + } | ||
582 | + T0 = 0; | ||
583 | + EXIT_TB(); | ||
584 | + } | ||
585 | + FORCE_RET(); | ||
586 | +} | ||
576 | #endif | 587 | #endif |
577 | 588 | ||
578 | /* port I/O */ | 589 | /* port I/O */ |