1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00

arm: fixed pc and listing for thumb

This commit is contained in:
Steven Hugg 2021-06-15 09:26:22 -05:00
parent a7f62079db
commit e7dc2ce750
2 changed files with 11 additions and 4 deletions

View File

@ -2749,7 +2749,7 @@ ARMCore.prototype.resetCPU = function(startOffset) {
ARMCore.prototype.freeze = function() : ARMCoreState {
return {
PC: this.gprs[15] - 4,
PC: this.gprs[15] - this.instructionWidth,
SP: this.gprs[13],
'gprs': [
this.gprs[0],
@ -4097,6 +4097,7 @@ ARMCore.prototype.compileThumb = function(instruction) {
op.execMode = ARMMode.MODE_THUMB;
op.fixedJump = op.fixedJump || false;
//console.log(hex(instruction), op);
return op;
};
@ -4137,7 +4138,7 @@ export class ARM32CPU implements CPU, InstructionBased, ARMMMUInterface, ARMIRQI
return n > 0 ? n : 1;
}
getPC(): number {
return this.core.gprs[15] - 4;
return this.core.gprs[15] - this.core.instructionWidth;
}
getSP(): number {
return this.core.gprs[13];

View File

@ -2935,8 +2935,14 @@ function assembleARMIPS(step:BuildStep) {
var lst = listings[path2];
if (lst == null) { lst = listings[path2] = {lines:[]}; }
var ofs = parseInt(m[1], 16);
var insn = objout.slice(ofs, ofs+4); // TODO: doesn't do thumb or !=4 bytes
if (lastofs == ofs) lst.lines.pop(); else lastofs = ofs;
var insn = objout.slice(ofs, ofs+4);
if (lastofs == ofs) {
lst.lines.pop(); // get rid of duplicate offset
} else if (lastofs+2 == ofs) {
var lastline = lst.lines[lst.lines.length-1]; // convert 4-byte to 2-byte insn
if (lastline && lastline.insns) lastline.insns = lastline.insns.substring(4,8);
}
lastofs = ofs;
lst.lines.push({
path: path,
line: parseInt(m[4]),