port fxrstor
This commit is contained in:
parent
d7b81d5bb9
commit
7c8294230d
|
@ -214,8 +214,6 @@ function V86Starter(options)
|
|||
"_jcxz": function() { return cpu.jcxz.apply(cpu, arguments); },
|
||||
"_test_privileges_for_io": function() { return cpu.test_privileges_for_io.apply(cpu, arguments); },
|
||||
|
||||
"_fxsave": function() { return cpu.fxsave.apply(cpu, arguments); },
|
||||
"_fxrstor": function() { return cpu.fxrstor.apply(cpu, arguments); },
|
||||
};
|
||||
|
||||
let wasm_file = DEBUG ? "v86-debug.wasm" : "v86.wasm";
|
||||
|
|
|
@ -370,6 +370,7 @@ CPU.prototype.wasm_patch = function(wm)
|
|||
this.outsd = this.wm.funcs['_outsd'];
|
||||
|
||||
this.fxsave = this.wm.funcs['_fxsave'];
|
||||
this.fxrstor = this.wm.funcs['_fxrstor'];
|
||||
};
|
||||
|
||||
CPU.prototype.get_state = function()
|
||||
|
|
|
@ -44,7 +44,7 @@ void safe_write16(int32_t, int32_t);
|
|||
void safe_write32(int32_t, int32_t);
|
||||
|
||||
void fxsave(uint32_t);
|
||||
void fxrstor(int32_t);
|
||||
void fxrstor(uint32_t);
|
||||
|
||||
int32_t do_page_translation(int32_t, bool, bool);
|
||||
|
||||
|
|
|
@ -290,7 +290,9 @@ void setcc(bool condition) {
|
|||
}
|
||||
|
||||
int32_t fpu_load_status_word();
|
||||
void fpu_set_status_word(int32_t);
|
||||
void fpu_store_m80(uint32_t, double_t);
|
||||
double_t fpu_load_m80(uint32_t);
|
||||
|
||||
void fxsave(uint32_t addr)
|
||||
{
|
||||
|
@ -325,3 +327,41 @@ void fxsave(uint32_t addr)
|
|||
}
|
||||
}
|
||||
|
||||
void fxrstor(uint32_t addr)
|
||||
{
|
||||
translate_address_read(addr);
|
||||
translate_address_read(addr + 511);
|
||||
|
||||
int32_t new_mxcsr = safe_read32s(addr + 24);
|
||||
|
||||
if(new_mxcsr & ~MXCSR_MASK)
|
||||
{
|
||||
//dbg_log("Invalid mxcsr bits: " + h((new_mxcsr & ~MXCSR_MASK) >>> 0, 8));
|
||||
trigger_gp(0);
|
||||
}
|
||||
|
||||
*fpu_control_word = safe_read16(addr + 0);
|
||||
fpu_set_status_word(safe_read16(addr + 2));
|
||||
*fpu_stack_empty = ~safe_read8(addr + 4) & 0xFF;
|
||||
*fpu_opcode = safe_read16(addr + 6);
|
||||
*fpu_ip = safe_read32s(addr + 8);
|
||||
*fpu_ip = safe_read16(addr + 12);
|
||||
*fpu_dp = safe_read32s(addr + 16);
|
||||
*fpu_dp_selector = safe_read16(addr + 20);
|
||||
|
||||
*mxcsr = new_mxcsr;
|
||||
|
||||
for(int32_t i = 0; i < 8; i++)
|
||||
{
|
||||
fpu_st[*fpu_stack_ptr + i & 7] = fpu_load_m80(addr + 32 + (i << 4));
|
||||
}
|
||||
|
||||
for(int32_t i = 0; i < 8; i++)
|
||||
{
|
||||
reg_xmm32s[i << 2 | 0] = safe_read32s(addr + 160 + (i << 4) + 0);
|
||||
reg_xmm32s[i << 2 | 1] = safe_read32s(addr + 160 + (i << 4) + 4);
|
||||
reg_xmm32s[i << 2 | 2] = safe_read32s(addr + 160 + (i << 4) + 8);
|
||||
reg_xmm32s[i << 2 | 3] = safe_read32s(addr + 160 + (i << 4) + 12);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue