[SOFTX86]

Fix some bugs of softx86, see CORE-7250 for more information.
All diffs from the original softx86 code should also be put in softx86_ros.diff.

svn path=/branches/ntvdm/; revision=59248
This commit is contained in:
Hermès Bélusca-Maïto 2013-06-16 23:54:30 +00:00
parent c8317ea346
commit dfd4fed945
3 changed files with 96 additions and 2 deletions

View file

@ -217,9 +217,9 @@ Sfx86OpcodeTable optab8086 = {
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x66 */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x67 */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x68 */
{Sfx86OpcodeExec_push, Sfx86OpcodeDec_push}, /* 0x68 */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x69 */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6A */
{Sfx86OpcodeExec_push, Sfx86OpcodeDec_push}, /* 0x6A */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6B */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6C */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6D */

View file

@ -167,6 +167,21 @@ int Sfx86OpcodeExec_push(sx86_ubyte opcode,softx86_ctx* ctx)
return 1;
}
if (opcode == 0x6A) // PUSH imm8
{
sx86_ubyte b = softx86_fetch_exec_byte(ctx);
softx86_stack_pushw(ctx, (sx86_uword)b);
return 1;
}
if (opcode == 0x68) // PUSH imm16
{
sx86_uword w = softx86_fetch_exec_byte(ctx);
w |= softx86_fetch_exec_byte(ctx) << 8;
softx86_stack_pushw(ctx, w);
return 1;
}
return 0;
}
@ -202,6 +217,21 @@ int Sfx86OpcodeDec_push(sx86_ubyte opcode,softx86_ctx* ctx,char buf[128])
return 1;
}
if (opcode == 0x6A && ctx->__private->level >= SX86_CPULEVEL_80186) // PUSH imm8
{
sx86_ubyte b = softx86_fetch_exec_byte(ctx);
sprintf(buf, "PUSH %02Xh", b);
return 1;
}
if (opcode == 0x68 && ctx->__private->level >= SX86_CPULEVEL_80186) // PUSH imm16
{
sx86_uword w = softx86_fetch_exec_byte(ctx);
w |= softx86_fetch_exec_byte(ctx) << 8;
sprintf(buf, "PUSH %04Xh", w);
return 1;
}
return 0;
}

64
lib/3rdparty/softx86/softx86_ros.diff vendored Normal file
View file

@ -0,0 +1,64 @@
Index: softx86/optable.c
===================================================================
--- softx86/optable.c (révision 59247)
+++ softx86/optable.c (copie de travail)
@@ -217,9 +217,9 @@
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x66 */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x67 */
- {Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x68 */
+ {Sfx86OpcodeExec_push, Sfx86OpcodeDec_push}, /* 0x68 */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x69 */
- {Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6A */
+ {Sfx86OpcodeExec_push, Sfx86OpcodeDec_push}, /* 0x6A */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6B */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6C */
{Sfx86OpcodeExec_default, Sfx86OpcodeDec_default}, /* 0x6D */
Index: softx86/pushpop.c
===================================================================
--- softx86/pushpop.c (révision 59247)
+++ softx86/pushpop.c (copie de travail)
@@ -167,6 +167,21 @@
return 1;
}
+ if (opcode == 0x6A) // PUSH imm8
+ {
+ sx86_ubyte b = softx86_fetch_exec_byte(ctx);
+ softx86_stack_pushw(ctx, (sx86_uword)b);
+ return 1;
+ }
+
+ if (opcode == 0x68) // PUSH imm16
+ {
+ sx86_uword w = softx86_fetch_exec_byte(ctx);
+ w |= softx86_fetch_exec_byte(ctx) << 8;
+ softx86_stack_pushw(ctx, w);
+ return 1;
+ }
+
return 0;
}
@@ -202,6 +217,21 @@
return 1;
}
+ if (opcode == 0x6A && ctx->__private->level >= SX86_CPULEVEL_80186) // PUSH imm8
+ {
+ sx86_ubyte b = softx86_fetch_exec_byte(ctx);
+ sprintf(buf, "PUSH %02Xh", b);
+ return 1;
+ }
+
+ if (opcode == 0x68 && ctx->__private->level >= SX86_CPULEVEL_80186) // PUSH imm16
+ {
+ sx86_uword w = softx86_fetch_exec_byte(ctx);
+ w |= softx86_fetch_exec_byte(ctx) << 8;
+ sprintf(buf, "PUSH %04Xh", w);
+ return 1;
+ }
+
return 0;
}