port idiv32
This commit is contained in:
parent
18b8ebf4ba
commit
f9d99ac4de
|
@ -195,7 +195,6 @@ function V86Starter(options)
|
|||
"_load_tr": function() { return cpu.load_tr.apply(cpu, arguments); },
|
||||
|
||||
"_idiv16": function() { return cpu.idiv16.apply(cpu, arguments); },
|
||||
"_idiv32": function() { return cpu.idiv32.apply(cpu, arguments); },
|
||||
"_insb": function() { return cpu.insb.apply(cpu, arguments); },
|
||||
"_insw": function() { return cpu.insw.apply(cpu, arguments); },
|
||||
"_insd": function() { return cpu.insd.apply(cpu, arguments); },
|
||||
|
|
|
@ -279,6 +279,7 @@ CPU.prototype.wasm_patch = function(wm)
|
|||
this.trigger_de = this.wm.funcs['_trigger_de'];
|
||||
this.trigger_gp = this.wm.funcs['_trigger_gp'];
|
||||
this.div32 = this.wm.funcs['_div32'];
|
||||
this.idiv32 = this.wm.funcs['_idiv32'];
|
||||
|
||||
this.shl8 = this.wm.funcs['_shl8'];
|
||||
this.shl16 = this.wm.funcs['_shl16'];
|
||||
|
|
|
@ -840,6 +840,38 @@ void div32(uint32_t source_operand)
|
|||
reg32s[EDX] = mod;
|
||||
}
|
||||
|
||||
void idiv32(int32_t source_operand)
|
||||
{
|
||||
if(source_operand == 0)
|
||||
{
|
||||
trigger_de();
|
||||
return;
|
||||
}
|
||||
|
||||
uint32_t target_low = reg32s[EAX];
|
||||
uint32_t target_high = reg32s[EDX];
|
||||
|
||||
int64_t target_operand = (((uint64_t) target_high) << 32) | ((uint64_t) target_low);
|
||||
|
||||
if(source_operand == -1 && target_operand == INT64_MIN)
|
||||
{
|
||||
trigger_de();
|
||||
return;
|
||||
}
|
||||
|
||||
int64_t result = target_operand / source_operand;
|
||||
if(result < INT32_MIN || result > INT32_MAX)
|
||||
{
|
||||
trigger_de();
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t mod = target_operand % source_operand;
|
||||
|
||||
reg32s[EAX] = result;
|
||||
reg32s[EDX] = mod;
|
||||
}
|
||||
|
||||
int32_t shl8(int32_t dest_operand, int32_t count)
|
||||
{
|
||||
if(count == 0)
|
||||
|
|
|
@ -184,7 +184,7 @@ int32_t rcl32(int32_t, int32_t);
|
|||
|
||||
int32_t idiv16(int32_t);
|
||||
void div32(uint32_t);
|
||||
int32_t idiv32(int32_t);
|
||||
void idiv32(int32_t);
|
||||
|
||||
|
||||
void insb(void);
|
||||
|
|
Loading…
Reference in a new issue