Skip to content

Commit

Permalink
Fix PC going > 65535
Browse files Browse the repository at this point in the history
  • Loading branch information
Kurumiiw committed Dec 8, 2024
1 parent ea96d0d commit 3c11712
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/components/emulator/emulator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -245,9 +245,6 @@ export default function Emulator() {
]

for(let step = 0; step < steps; step++) {
if(PC > 65535)
PC = PC - 65536;

if(PC < 0)
PC = 65535 + PC + 1

Expand Down Expand Up @@ -425,6 +422,10 @@ export default function Emulator() {
}

PC = didJump ? PC : PC + 1;

if(PC > 65535) {
PC = PC - 65536;
}
}

setReg_PC(PC);
Expand Down Expand Up @@ -721,8 +722,6 @@ export default function Emulator() {

const setRegisterSrcDest = (memoryAddr: number, reg: number, type: number) => {
ram[memoryAddr] |= parseInt(('000' + reg.toString(2)).slice(-3).split("").reverse().join(""), 2) << (7 + type * 3);

byteCount += 2;
}

const findRegisterTokenOffset = (i: number, token: number) => {
Expand Down Expand Up @@ -797,7 +796,6 @@ export default function Emulator() {
immVal = 65536 + immVal;

ram[addr++] = immVal;
byteCount += 2;

break;
}
Expand Down Expand Up @@ -825,7 +823,6 @@ export default function Emulator() {
immVal = 65536 + immVal;

ram[addr++] = immVal;
byteCount += 2;
}

error = false;
Expand Down

0 comments on commit 3c11712

Please sign in to comment.