port movsw
This commit is contained in:
parent
f6c2e4ca97
commit
a9edccebc7
|
@ -200,7 +200,6 @@ function V86Starter(options)
|
|||
"_outsb": function() { return cpu.outsb.apply(cpu, arguments); },
|
||||
"_outsw": function() { return cpu.outsw.apply(cpu, arguments); },
|
||||
"_outsd": function() { return cpu.outsd.apply(cpu, arguments); },
|
||||
"_movsw": function() { return cpu.movsw.apply(cpu, arguments); },
|
||||
"_movsd": function() { return cpu.movsd.apply(cpu, arguments); },
|
||||
"_cmpsb": function() { return cpu.cmpsb.apply(cpu, arguments); },
|
||||
"_cmpsw": function() { return cpu.cmpsw.apply(cpu, arguments); },
|
||||
|
|
|
@ -346,6 +346,7 @@ CPU.prototype.wasm_patch = function(wm)
|
|||
this.add_reg_asize = this.wm.funcs['_add_reg_asize'];
|
||||
this.decr_ecx_asize = this.wm.funcs['_decr_ecx_asize'];
|
||||
this.movsb = this.wm.funcs['_movsb'];
|
||||
this.movsw = this.wm.funcs['_movsw'];
|
||||
};
|
||||
|
||||
CPU.prototype.get_state = function()
|
||||
|
|
|
@ -84,3 +84,81 @@ void movsb()
|
|||
}
|
||||
}
|
||||
|
||||
void movsw_rep()
|
||||
{
|
||||
int32_t src = get_seg_prefix(DS) + get_reg_asize(ESI);
|
||||
int32_t dest = get_seg(ES) + get_reg_asize(EDI);
|
||||
int32_t size = *flags & FLAG_DIRECTION ? -2 : 2;
|
||||
|
||||
int32_t count = get_reg_asize(ECX) >> 0;
|
||||
if(count == 0) return;
|
||||
int32_t cont = false;
|
||||
int32_t start_count = count;
|
||||
int32_t cycle_counter = MAX_COUNT_PER_CYCLE;
|
||||
if(!(dest & 1) && !(src & 1))
|
||||
{
|
||||
int32_t single_size = size < 0 ? -1 : 1;
|
||||
int32_t phys_src = translate_address_read(src) >> 1;
|
||||
int32_t phys_dest = translate_address_write(dest) >> 1;
|
||||
if(*paging)
|
||||
{
|
||||
cycle_counter = string_get_cycle_count2(size, src, dest);
|
||||
}
|
||||
do
|
||||
{
|
||||
write_aligned16(phys_dest, read_aligned16(phys_src));
|
||||
phys_dest += single_size;
|
||||
phys_src += single_size;
|
||||
cont = --count != 0;
|
||||
}
|
||||
while(cont && cycle_counter--);
|
||||
int32_t diff = size * (start_count - count) | 0;
|
||||
add_reg_asize(EDI, diff);
|
||||
add_reg_asize(ESI, diff);
|
||||
set_ecx_asize(count);
|
||||
*timestamp_counter += start_count - count;
|
||||
}
|
||||
else
|
||||
{
|
||||
do
|
||||
{
|
||||
safe_write16(dest, safe_read16(src));
|
||||
dest += size;
|
||||
add_reg_asize(EDI, size);
|
||||
src += size;
|
||||
add_reg_asize(ESI, size);
|
||||
cont = decr_ecx_asize() != 0;
|
||||
}
|
||||
while(cont && cycle_counter--);
|
||||
}
|
||||
if(cont)
|
||||
{
|
||||
*instruction_pointer = *previous_ip;
|
||||
}
|
||||
diverged();
|
||||
}
|
||||
|
||||
void movsw_no_rep()
|
||||
{
|
||||
int32_t src = get_seg_prefix(DS) + get_reg_asize(ESI);
|
||||
int32_t dest = get_seg(ES) + get_reg_asize(EDI);
|
||||
int32_t size = *flags & FLAG_DIRECTION ? -2 : 2;
|
||||
|
||||
safe_write16(dest, safe_read16(src));
|
||||
add_reg_asize(EDI, size);
|
||||
add_reg_asize(ESI, size);
|
||||
diverged();
|
||||
}
|
||||
|
||||
void movsw()
|
||||
{
|
||||
if(*prefixes & PREFIX_MASK_REP)
|
||||
{
|
||||
movsw_rep();
|
||||
}
|
||||
else
|
||||
{
|
||||
movsw_no_rep();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue