Improve stack operations
This commit is contained in:
parent
4eb09fc11d
commit
d9167c7d61
|
@ -966,11 +966,13 @@ opm2(0xC7, { set_ev16(cpu.read_imm16()); }, { set_ev32(cpu.read_imm32s()); })
|
|||
op2(0xC8, { cpu.enter16(); }, { cpu.enter32(); });
|
||||
op2(0xC9, {
|
||||
// leave
|
||||
cpu.stack_reg[cpu.reg_vsp] = cpu.stack_reg[cpu.reg_vbp];
|
||||
cpu.reg16[reg_bp] = cpu.pop16();
|
||||
var new_bp = cpu.safe_read16(cpu.get_seg(reg_ss) + cpu.stack_reg[cpu.reg_vbp] | 0);
|
||||
cpu.stack_reg[cpu.reg_vsp] = cpu.stack_reg[cpu.reg_vbp] + 2 | 0;
|
||||
cpu.reg16[reg_bp] = new_bp;
|
||||
}, {
|
||||
cpu.stack_reg[cpu.reg_vsp] = cpu.stack_reg[cpu.reg_vbp];
|
||||
cpu.reg32s[reg_ebp] = cpu.pop32s();
|
||||
var new_ebp = cpu.safe_read32s(cpu.get_seg(reg_ss) + cpu.stack_reg[cpu.reg_vbp] | 0);
|
||||
cpu.stack_reg[cpu.reg_vsp] = cpu.stack_reg[cpu.reg_vbp] + 4 | 0;
|
||||
cpu.reg32s[reg_ebp] = new_ebp;
|
||||
});
|
||||
op2(0xCA, {
|
||||
// retf
|
||||
|
|
|
@ -256,7 +256,7 @@ CPU.prototype.pusha16 = function()
|
|||
|
||||
// make sure we don't get a pagefault after having
|
||||
// pushed several registers already
|
||||
this.translate_address_write(this.get_seg(reg_ss) + temp - 15 | 0);
|
||||
this.translate_address_write(this.get_seg(reg_ss) + this.stack_reg[this.reg_vsp] - 15 | 0);
|
||||
|
||||
this.push16(this.reg16[reg_ax]);
|
||||
this.push16(this.reg16[reg_cx]);
|
||||
|
@ -272,7 +272,7 @@ CPU.prototype.pusha32 = function()
|
|||
{
|
||||
var temp = this.reg32s[reg_esp];
|
||||
|
||||
this.translate_address_write(this.get_seg(reg_ss) + temp - 31 | 0);
|
||||
this.translate_address_write(this.get_seg(reg_ss) + this.stack_reg[this.reg_vsp] - 31 | 0);
|
||||
|
||||
this.push32(this.reg32s[reg_eax]);
|
||||
this.push32(this.reg32s[reg_ecx]);
|
||||
|
|
Loading…
Reference in a new issue