Compare commits
2 Commits
incrementP
...
callInstru
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
022dd499ce | ||
|
|
3eaf697306 |
@@ -13,13 +13,12 @@ class Main
|
||||
|
||||
ArrayList<Command> program = new ArrayList<>();
|
||||
Memory.workingRegister = 0xAA;
|
||||
int input1 = 0x2FFF;
|
||||
int input1 = 0x27FF;
|
||||
program.add(CommandDecoder.decode(input1));
|
||||
|
||||
Memory.setPCLATH(0xFF);
|
||||
program.get(0).execute();
|
||||
|
||||
//ProgramCounter.incPC();
|
||||
|
||||
}
|
||||
}
|
||||
21
de/darkress/pic16f84sim/commands/Call.java
Normal file
21
de/darkress/pic16f84sim/commands/Call.java
Normal file
@@ -0,0 +1,21 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
import de.darkress.pic16f84sim.microcontroller.Stack;
|
||||
|
||||
public class Call extends CommandUtils implements Command
|
||||
{
|
||||
private final int literal;
|
||||
|
||||
public Call(int input)
|
||||
{
|
||||
literal = input & 0x07FF;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
Stack.push(ProgramCounter.getPc() + 1);
|
||||
ProgramCounter.setPcFrom11BitLiteral(literal);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,5 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Goto extends CommandUtils implements Command
|
||||
@@ -15,6 +14,6 @@ public class Goto extends CommandUtils implements Command
|
||||
@Override
|
||||
public void execute()
|
||||
{
|
||||
ProgramCounter.setPcForGotoCall(literal);
|
||||
ProgramCounter.setPcFrom11BitLiteral(literal);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,8 +100,7 @@ public class CommandDecoder
|
||||
switch(input & 0x3800)
|
||||
{
|
||||
case 0x2000:
|
||||
//call();
|
||||
break;
|
||||
return new Call(input);
|
||||
case 0x2800:
|
||||
return new Goto(input);
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ public class ProgramCounter
|
||||
return pc;
|
||||
}
|
||||
|
||||
public static void setPcForGotoCall(int data)
|
||||
public static void setPcFrom11BitLiteral(int data)
|
||||
{
|
||||
int pcl = data & 0x00FF;
|
||||
int pch = Memory.getPCLATH();
|
||||
|
||||
Reference in New Issue
Block a user