Skip to content

Commit

Permalink
Still not right, but fixes all known timing issues
Browse files Browse the repository at this point in the history
  • Loading branch information
endrift committed Mar 29, 2013
1 parent 9eb7dff commit 0f8a214
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 59 deletions.
46 changes: 23 additions & 23 deletions js/arm.js
Original file line number Diff line number Diff line change
Expand Up @@ -584,9 +584,9 @@ ARMCoreArm.prototype.constructB = function(immediate, condOp) {
cpu.mmu.waitSeq32(gprs[cpu.PC]);
return;
}
cpu.mmu.wait32(gprs[cpu.PC]);
gprs[cpu.PC] += immediate;
cpu.mmu.waitSeq32(gprs[cpu.PC]);
gprs[cpu.PC] += immediate;
cpu.mmu.wait32(gprs[cpu.PC]);
cpu.mmu.waitSeq32(gprs[cpu.PC]);
};
};
Expand Down Expand Up @@ -632,10 +632,10 @@ ARMCoreArm.prototype.constructBL = function(immediate, condOp) {
cpu.mmu.waitSeq32(gprs[cpu.PC]);
return;
}
cpu.mmu.wait32(gprs[cpu.PC]);
cpu.mmu.waitSeq32(gprs[cpu.PC]);
gprs[cpu.LR] = gprs[cpu.PC] - 4;
gprs[cpu.PC] += immediate;
cpu.mmu.waitSeq32(gprs[cpu.PC]);
cpu.mmu.wait32(gprs[cpu.PC]);
cpu.mmu.waitSeq32(gprs[cpu.PC]);
};
};
Expand All @@ -648,14 +648,14 @@ ARMCoreArm.prototype.constructBX = function(rm, condOp) {
cpu.mmu.waitSeq32(gprs[cpu.PC]);
return;
}
cpu.mmu.wait(gprs[cpu.PC]);
cpu.mmu.waitSeq32(gprs[cpu.PC]);
cpu.switchExecMode(gprs[rm] & 0x00000001);
gprs[cpu.PC] = gprs[rm] & 0xFFFFFFFE;
if (cpu.execMode == cpu.MODE_THUMB) {
cpu.mmu.waitSeq(gprs[cpu.PC]);
cpu.mmu.wait(gprs[cpu.PC]);
cpu.mmu.waitSeq(gprs[cpu.PC]);
} else {
cpu.mmu.waitSeq32(gprs[cpu.PC]);
cpu.mmu.wait32(gprs[cpu.PC]);
cpu.mmu.waitSeq32(gprs[cpu.PC]);
}
};
Expand Down Expand Up @@ -736,7 +736,7 @@ ARMCoreArm.prototype.constructLDM = function(rs, address, condOp) {
var gprs = cpu.gprs;
var mmu = cpu.mmu;
return function() {
mmu.wait32(gprs[cpu.PC]);
mmu.waitSeq32(gprs[cpu.PC]);
if (condOp && !condOp()) {
return;
}
Expand All @@ -760,7 +760,7 @@ ARMCoreArm.prototype.constructLDMS = function(rs, address, condOp) {
var gprs = cpu.gprs;
var mmu = cpu.mmu;
return function() {
mmu.wait32(gprs[cpu.PC]);
mmu.waitSeq32(gprs[cpu.PC]);
if (condOp && !condOp()) {
return;
}
Expand Down Expand Up @@ -791,9 +791,9 @@ ARMCoreArm.prototype.constructLDR = function(rd, address, condOp) {
return;
}
var addr = address();
++cpu.cycles;
cpu.mmu.wait32(addr);
gprs[rd] = cpu.mmu.load32(addr);
cpu.mmu.wait32(addr);
++cpu.cycles;
};
};

Expand All @@ -806,9 +806,9 @@ ARMCoreArm.prototype.constructLDRB = function(rd, address, condOp) {
return;
}
var addr = address();
++cpu.cycles;
cpu.mmu.wait(addr);
gprs[rd] = cpu.mmu.loadU8(addr);
cpu.mmu.wait(addr);
++cpu.cycles;
};
};

Expand All @@ -821,9 +821,9 @@ ARMCoreArm.prototype.constructLDRH = function(rd, address, condOp) {
return;
}
var addr = address();
++cpu.cycles;
cpu.mmu.wait(addr);
gprs[rd] = cpu.mmu.loadU16(addr);
cpu.mmu.wait(addr);
++cpu.cycles;
};
};

Expand All @@ -836,9 +836,9 @@ ARMCoreArm.prototype.constructLDRSB = function(rd, address, condOp) {
return;
}
var addr = address();
++cpu.cycles;
cpu.mmu.wait(addr);
gprs[rd] = cpu.mmu.load8(addr);
cpu.mmu.wait(addr);
++cpu.cycles;
};
};

Expand All @@ -851,9 +851,9 @@ ARMCoreArm.prototype.constructLDRSH = function(rd, address, condOp) {
return;
}
var addr = address();
++cpu.cycles;
cpu.mmu.wait(addr);
gprs[rd] = cpu.mmu.load16(addr);
cpu.mmu.wait(addr);
++cpu.cycles;
};
};

Expand Down Expand Up @@ -1299,6 +1299,7 @@ ARMCoreArm.prototype.constructSTM = function(rs, address, condOp) {
mmu.waitSeq32(gprs[cpu.PC]);
return;
}
mmu.wait32(gprs[cpu.PC]);
var addr = address(true);
var total = 0;
var m, i;
Expand All @@ -1310,7 +1311,6 @@ ARMCoreArm.prototype.constructSTM = function(rs, address, condOp) {
}
}
mmu.waitMulti32(addr, total);
mmu.wait32(gprs[cpu.PC]);
};
};

Expand All @@ -1323,6 +1323,7 @@ ARMCoreArm.prototype.constructSTMS = function(rs, address, condOp) {
mmu.waitSeq32(gprs[cpu.PC]);
return;
}
mmu.wait32(gprs[cpu.PC]);
var mode = cpu.mode;
var addr = address(true);
var total = 0;
Expand All @@ -1337,7 +1338,6 @@ ARMCoreArm.prototype.constructSTMS = function(rs, address, condOp) {
}
cpu.switchMode(mode);
mmu.waitMulti32(addr, total);
mmu.wait32(gprs[cpu.PC]);
};
};

Expand Down Expand Up @@ -1431,9 +1431,9 @@ ARMCoreArm.prototype.constructSWI = function(immediate, condOp) {
return;
}
cpu.irq.swi32(immediate);
cpu.mmu.wait32(gprs[cpu.PC]);
cpu.mmu.waitSeq32(gprs[cpu.PC]);
// Wait on BIOS
cpu.mmu.waitSeq32(0);
cpu.mmu.wait32(0);
cpu.mmu.waitSeq32(0);
};
};
Expand Down
Loading

0 comments on commit 0f8a214

Please sign in to comment.