callInstruction #3

Merged
Darkress merged 2 commits from callInstruction into main 2023-05-30 01:19:59 +02:00
5 changed files with 5 additions and 8 deletions
Showing only changes of commit 022dd499ce - Show all commits

View File

@@ -13,7 +13,7 @@ class Main
ArrayList<Command> program = new ArrayList<>(); ArrayList<Command> program = new ArrayList<>();
Memory.workingRegister = 0xAA; Memory.workingRegister = 0xAA;
int input1 = 0x2FFF; int input1 = 0x27FF;
program.add(CommandDecoder.decode(input1)); program.add(CommandDecoder.decode(input1));
Memory.setPCLATH(0xFF); Memory.setPCLATH(0xFF);

View File

@@ -1,6 +1,5 @@
package de.darkress.pic16f84sim.commands; package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter; import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
import de.darkress.pic16f84sim.microcontroller.Stack; import de.darkress.pic16f84sim.microcontroller.Stack;
@@ -17,6 +16,6 @@ public class Call extends CommandUtils implements Command
public void execute() public void execute()
{ {
Stack.push(ProgramCounter.getPc() + 1); Stack.push(ProgramCounter.getPc() + 1);
ProgramCounter.setPcForGotoCall(literal); ProgramCounter.setPcFrom11BitLiteral(literal);
} }
} }

View File

@@ -1,6 +1,5 @@
package de.darkress.pic16f84sim.commands; package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter; import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Goto extends CommandUtils implements Command public class Goto extends CommandUtils implements Command
@@ -15,6 +14,6 @@ public class Goto extends CommandUtils implements Command
@Override @Override
public void execute() public void execute()
{ {
ProgramCounter.setPcForGotoCall(literal); ProgramCounter.setPcFrom11BitLiteral(literal);
} }
} }

View File

@@ -100,8 +100,7 @@ public class CommandDecoder
switch(input & 0x3800) switch(input & 0x3800)
{ {
case 0x2000: case 0x2000:
//call(); return new Call(input);
break;
case 0x2800: case 0x2800:
return new Goto(input); return new Goto(input);
} }

View File

@@ -11,7 +11,7 @@ public class ProgramCounter
return pc; return pc;
} }
public static void setPcForGotoCall(int data) public static void setPcFrom11BitLiteral(int data)
{ {
int pcl = data & 0x00FF; int pcl = data & 0x00FF;
int pch = Memory.getPCLATH(); int pch = Memory.getPCLATH();