fixed PC (#6)

Co-authored-by: Darkress <30271678+DarkressX@users.noreply.github.com>
Reviewed-on: darkress/pic16f84-sim#6
This commit was merged in pull request #6.
This commit is contained in:
darkress
2023-05-31 14:22:45 +02:00
parent 2cfc14ba78
commit 0b5d0c172a
4 changed files with 23 additions and 18 deletions

View File

@@ -20,19 +20,20 @@ public class ProgramCounter
pc = (pch) + pcl;
}
public static void setPcFromStack(int stack)
{
pc = stack;
Memory.setPCL(pc & 0x00FF);
}
public static void loadPc()
{
pc = (Memory.getPCLATH() <<8) + Memory.getPCL();
}
public static void incPC() //is called after every instruction execution
{
int pcl = Memory.getPCL();
int pclath = Memory.getPCLATH();
if(pcl == 0xFF)
{
pclath++;
pcl = 0;
} else {
pcl++;
}
Memory.setPCL(pcl);
Memory.setPCLATH(pclath);
pc = (pclath <<8) + pcl;
pc++;
Memory.setPCL(pc & 0x00FF);
}
}