more instructions
This commit is contained in:
@@ -58,23 +58,37 @@ void JIT::daddiu(u32 instr) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JIT::div(u32 instr) {
|
void JIT::div(u32 instr) {
|
||||||
|
movsxd(rax, dword[rdi + offsetof(Registers, gpr[RS(instr)])]); // dividend
|
||||||
|
movsxd(rcx, dword[rdi + offsetof(Registers, gpr[RS(instr)])]); // divisor
|
||||||
|
cmp(rcx, 0);
|
||||||
|
je("divisor==0");
|
||||||
|
|
||||||
|
CodeGenerator::div(rcx);
|
||||||
|
mov(qword[rdi + offsetof(Registers, lo)], eax);
|
||||||
|
mov(qword[rdi + offsetof(Registers, hi)], edx);
|
||||||
|
|
||||||
|
L("divisor==0");
|
||||||
|
mov(qword[rdi + offsetof(Registers, hi)], rax);
|
||||||
|
cmp(rax, 0);
|
||||||
|
jge("dividend>=0");
|
||||||
|
mov(qword[rdi + offsetof(Registers, lo)], s64(1));
|
||||||
|
L("dividend>=0");
|
||||||
|
mov(qword[rdi + offsetof(Registers, lo)], s64(-1));
|
||||||
}
|
}
|
||||||
|
|
||||||
void JIT::divu(u32 instr) {
|
void JIT::divu(u32 instr) {
|
||||||
mov(rax, dword[rdi + offsetof(Registers, gpr[RS(instr)])]);
|
movsxd(rax, dword[rdi + offsetof(Registers, gpr[RS(instr)])]); // dividend
|
||||||
mov(rcx, dword[rdi + offsetof(Registers, gpr[RS(instr)])]);
|
movsxd(rcx, dword[rdi + offsetof(Registers, gpr[RS(instr)])]); // divisor
|
||||||
cmp(rcx, 0);
|
cmp(rcx, 0);
|
||||||
je("");
|
je("divisor==0");
|
||||||
if(divisor == 0) {
|
|
||||||
regs.lo = -1;
|
CodeGenerator::div(rcx);
|
||||||
regs.hi = (s32)dividend;
|
mov(qword[rdi + offsetof(Registers, lo)], eax);
|
||||||
} else {
|
mov(qword[rdi + offsetof(Registers, hi)], edx);
|
||||||
s32 quotient = (s32)(dividend / divisor);
|
|
||||||
s32 remainder = (s32)(dividend % divisor);
|
L("divisor==0");
|
||||||
regs.lo = quotient;
|
mov(qword[rdi + offsetof(Registers, hi)], rax);
|
||||||
regs.hi = remainder;
|
mov(qword[rdi + offsetof(Registers, lo)], -1);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void JIT::ddiv(u32 instr) {
|
void JIT::ddiv(u32 instr) {
|
||||||
@@ -159,9 +173,10 @@ void JIT::bllink(u32 instr, bool cond) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JIT::lui(u32 instr) {
|
void JIT::lui(u32 instr) {
|
||||||
u64 val = s64((s16)instr);
|
u64 val = s64(s16(instr));
|
||||||
val <<= 16;
|
val <<= 16;
|
||||||
regs.gpr[RT(instr)] = val;
|
mov(qword[rdi + offsetof(Registers, gpr[RT(instr)])],
|
||||||
|
val);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JIT::lb(u32 instr) {
|
void JIT::lb(u32 instr) {
|
||||||
|
|||||||
Reference in New Issue
Block a user