Compare commits
3 Commits
btfssInstr
...
cycleCount
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97e2c26d01 | ||
|
|
2a24c2058f | ||
|
|
184c49f3ae |
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Addlw extends LiteralCommandUtils implements Command
|
||||
|
||||
Memory.workingRegister = result % 256;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -25,5 +26,6 @@ public class Addwf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Andlw extends LiteralCommandUtils implements Command
|
||||
{
|
||||
@@ -18,5 +20,7 @@ public class Andlw extends LiteralCommandUtils implements Command
|
||||
checkZeroBit(result);
|
||||
|
||||
Memory.workingRegister = result % 256;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Andwf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -22,5 +23,6 @@ public class Bcf extends BitOrientedCommandUtils implements Command
|
||||
|
||||
Memory.setRegister(address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -22,5 +23,6 @@ public class Bsf extends BitOrientedCommandUtils implements Command
|
||||
|
||||
Memory.setRegister(address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -22,8 +23,10 @@ public class Btfsc extends BitOrientedCommandUtils implements Command
|
||||
if((result & (1 << bitPlacement)) == 0) //Test if bit is clear
|
||||
{
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -22,8 +23,10 @@ public class Btfss extends BitOrientedCommandUtils implements Command
|
||||
if((result & (1 << bitPlacement)) > 0) //Test if bit is set
|
||||
{
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
import de.darkress.pic16f84sim.microcontroller.Stack;
|
||||
|
||||
@@ -17,5 +18,6 @@ public class Call extends LiteralCommandUtils implements Command
|
||||
{
|
||||
Stack.push(ProgramCounter.getPc() + 1);
|
||||
ProgramCounter.setPcFrom11BitLiteral(literal);
|
||||
Cycles.addToCycles(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Clrf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -14,5 +15,6 @@ public class Clrw extends FileRegisterCommandUtils implements Command
|
||||
|
||||
Memory.workingRegister = result;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Comf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Decf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result % 256); // Catch underflow
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -25,9 +26,10 @@ public class Decfsz extends FileRegisterCommandUtils implements Command
|
||||
|
||||
if((result % 256) == 0)
|
||||
{
|
||||
Nop nop = new Nop();
|
||||
nop.execute(); // TODO: What happens if an interrupt gets triggered during the nop execution?
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Goto extends LiteralCommandUtils implements Command
|
||||
@@ -15,5 +16,6 @@ public class Goto extends LiteralCommandUtils implements Command
|
||||
public void execute()
|
||||
{
|
||||
ProgramCounter.setPcFrom11BitLiteral(literal);
|
||||
Cycles.addToCycles(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Incf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result % 256); // Catch underflow
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -25,9 +26,10 @@ public class Incfsz extends FileRegisterCommandUtils implements Command
|
||||
|
||||
if((result % 256) == 0)
|
||||
{
|
||||
Nop nop = new Nop();
|
||||
nop.execute(); // TODO: What happens if an interrupt gets triggered during the nop execution?
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Iorlw extends LiteralCommandUtils implements Command
|
||||
{
|
||||
@@ -18,5 +20,7 @@ public class Iorlw extends LiteralCommandUtils implements Command
|
||||
checkZeroBit(result);
|
||||
|
||||
Memory.workingRegister = result % 256;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Iorwf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Movf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -17,5 +18,6 @@ public class Movlw extends LiteralCommandUtils implements Command
|
||||
{
|
||||
Memory.workingRegister = literal;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -21,5 +22,6 @@ public class Movwf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Nop extends LiteralCommandUtils implements Command
|
||||
@@ -10,5 +11,6 @@ public class Nop extends LiteralCommandUtils implements Command
|
||||
{
|
||||
// Do nothing, just increment the PC
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
import de.darkress.pic16f84sim.microcontroller.Stack;
|
||||
@@ -18,5 +19,6 @@ public class Retlw extends LiteralCommandUtils implements Command
|
||||
{
|
||||
Memory.workingRegister = literal;
|
||||
ProgramCounter.setPcFromStack(Stack.pop());
|
||||
Cycles.addToCycles(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
import de.darkress.pic16f84sim.microcontroller.Stack;
|
||||
|
||||
@@ -9,5 +10,6 @@ public class Return extends LiteralCommandUtils implements Command
|
||||
public void execute()
|
||||
{
|
||||
ProgramCounter.setPcFromStack(Stack.pop());
|
||||
Cycles.addToCycles(2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -31,5 +32,6 @@ public class Rlf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, register);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -31,5 +32,6 @@ public class Rrf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, register);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Sublw extends LiteralCommandUtils implements Command
|
||||
{
|
||||
@@ -41,5 +43,7 @@ public class Sublw extends LiteralCommandUtils implements Command
|
||||
checkDigitCarryBit(literal);
|
||||
|
||||
Memory.workingRegister = result % 256;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -45,5 +46,6 @@ public class Subwf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result % 256);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Swapf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
public class Xorlw extends LiteralCommandUtils implements Command
|
||||
{
|
||||
@@ -18,5 +20,7 @@ public class Xorlw extends LiteralCommandUtils implements Command
|
||||
checkZeroBit(result);
|
||||
|
||||
Memory.workingRegister = result % 256;
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package de.darkress.pic16f84sim.commands;
|
||||
|
||||
import de.darkress.pic16f84sim.microcontroller.Cycles;
|
||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||
|
||||
@@ -23,5 +24,6 @@ public class Xorwf extends FileRegisterCommandUtils implements Command
|
||||
|
||||
writeToDestination(destinationBit, address, result);
|
||||
ProgramCounter.incPC();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
14
de/darkress/pic16f84sim/microcontroller/Cycles.java
Normal file
14
de/darkress/pic16f84sim/microcontroller/Cycles.java
Normal file
@@ -0,0 +1,14 @@
|
||||
package de.darkress.pic16f84sim.microcontroller;
|
||||
|
||||
public class Cycles {
|
||||
private static int cycles = 0;
|
||||
|
||||
public static void addToCycles(int increase)
|
||||
{
|
||||
cycles += increase;
|
||||
}
|
||||
|
||||
public static int getCycles() {
|
||||
return cycles;
|
||||
}
|
||||
}
|
||||
@@ -62,6 +62,7 @@ public class Memory
|
||||
if(address == 0x2) //Check if PCL is destination
|
||||
{
|
||||
ProgramCounter.loadPc();
|
||||
Cycles.addToCycles(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user