]> git.proxmox.com Git - qemu.git/commitdiff
fixed pop %sp bug
authorbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 13 Nov 2003 23:09:07 +0000 (23:09 +0000)
committerbellard <bellard@c046a42c-6fe2-441c-8c8c-71466251a162>
Thu, 13 Nov 2003 23:09:07 +0000 (23:09 +0000)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@458 c046a42c-6fe2-441c-8c8c-71466251a162

target-i386/translate.c

index 8457b6c237b6595b9a27d94b45a426b7d86807e0..3ab09a32803423e62320443a881777531eca6042 100644 (file)
@@ -2304,8 +2304,9 @@ static uint8_t *disas_insn(DisasContext *s, uint8_t *pc_start)
     case 0x58 ... 0x5f: /* pop */
         ot = dflag ? OT_LONG : OT_WORD;
         gen_pop_T0(s);
-        gen_op_mov_reg_T0[ot][b & 7]();
+        /* NOTE: order is important for pop %sp */
         gen_pop_update(s);
+        gen_op_mov_reg_T0[ot][b & 7]();
         break;
     case 0x60: /* pusha */
         gen_pusha(s);
@@ -2326,11 +2327,20 @@ static uint8_t *disas_insn(DisasContext *s, uint8_t *pc_start)
     case 0x8f: /* pop Ev */
         ot = dflag ? OT_LONG : OT_WORD;
         modrm = ldub_code(s->pc++);
+        mod = (modrm >> 6) & 3;
         gen_pop_T0(s);
-        s->popl_esp_hack = 2 << dflag;
-        gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
-        s->popl_esp_hack = 0;
-        gen_pop_update(s);
+        if (mod == 3) {
+            /* NOTE: order is important for pop %sp */
+            gen_pop_update(s);
+            rm = modrm & 7;
+            gen_op_mov_reg_T0[ot][rm]();
+        } else {
+            /* NOTE: order is important too for MMU exceptions */
+            s->popl_esp_hack = 2 << dflag;
+            gen_ldst_modrm(s, modrm, ot, OR_TMP0, 1);
+            s->popl_esp_hack = 0;
+            gen_pop_update(s);
+        }
         break;
     case 0xc8: /* enter */
         {