Skip to content
Permalink
Browse files

new_dynarec: Implemented emit_sub64_32 on x86

  • Loading branch information...
Gillou68310
Gillou68310 committed Dec 12, 2014
1 parent 77b0327 commit 5c1c8cc19455008b11162880b4bea469bfcd3c84
Showing with 44 additions and 5 deletions.
  1. +31 −0 src/r4300/new_dynarec/assem_x86.c
  2. +13 −5 src/r4300/new_dynarec/new_dynarec.c
@@ -1166,6 +1166,37 @@ static void emit_addimm64_32(int rsh,int rsl,int imm,int rth,int rtl)
}
}

static void emit_sub64_32(int rs1l,int rs1h,int rs2l,int rs2h,int rtl,int rth)
{
if((rs1l==rtl)&&(rs1h==rth)) {
assem_debug("sub %%%s,%%%s",regname[rs2l],regname[rs1l]);
output_byte(0x29);
output_modrm(3,rs1l,rs2l);
assem_debug("sbb %%%s,%%%s",regname[rs2h],regname[rs1h]);
output_byte(0x19);
output_modrm(3,rs1h,rs2h);
} else if((rs2l==rtl)&&(rs2h==rth)) {
emit_neg(rs2l,rs2l);
emit_adcimm(-1,rs2h);
assem_debug("add %%%s,%%%s",regname[rs1l],regname[rs2l]);
output_byte(0x01);
output_modrm(3,rs2l,rs1l);
emit_not(rs2h,rs2h);
assem_debug("adc %%%s,%%%s",regname[rs1h],regname[rs2h]);
output_byte(0x11);
output_modrm(3,rs2h,rs1h);
} else {
emit_mov(rs1l,rtl);
assem_debug("sub %%%s,%%%s",regname[rs2l],regname[rtl]);
output_byte(0x29);
output_modrm(3,rtl,rs2l);
emit_mov(rs1h,rth);
assem_debug("sbb %%%s,%%%s",regname[rs2h],regname[rth]);
output_byte(0x19);
output_modrm(3,rth,rs2h);
}
}

static void emit_sbb(int rs1,int rs2)
{
assem_debug("sbb %%%s,%%%s",regname[rs1],regname[rs2]);
@@ -2123,15 +2123,23 @@ static void alu_assemble(int i,struct regstat *i_regs)
if(rs1[i]&&rs2[i]) {
assert(s1l>=0);
assert(s2l>=0);
if(opcode2[i]&2) emit_subs(s1l,s2l,tl);
else emit_adds(s1l,s2l,tl);
if(th>=0) {
#ifdef INVERTED_CARRY
if(opcode2[i]&2) {if(s1h!=th) emit_mov(s1h,th);emit_sbb(th,s2h);}
if(opcode2[i]&2) emit_sub64_32(s1l,s1h,s2l,s2h,tl,th);
#else
if(opcode2[i]&2) emit_sbc(s1h,s2h,th);
if(opcode2[i]&2) {
emit_subs(s1l,s2l,tl);
emit_sbc(s1h,s2h,th);
}
#endif
else emit_adc(s1h,s2h,th);
else {
emit_adds(s1l,s2l,tl);
emit_adc(s1h,s2h,th);
}
}
else {
if(opcode2[i]&2) emit_subs(s1l,s2l,tl);
else emit_adds(s1l,s2l,tl);
}
}
else if(rs1[i]) {

0 comments on commit 5c1c8cc

Please sign in to comment.
You can’t perform that action at this time.