Compare commits

..

2 Commits

Author SHA1 Message Date
Darkress
022dd499ce Renamed setPcForGotoCall function to setPcFrom11BitLiteral 2023-05-30 01:18:51 +02:00
Darkress
3eaf697306 implemented Call instruction 2023-05-30 01:06:12 +02:00
4 changed files with 11 additions and 23 deletions

View File

@@ -12,14 +12,13 @@ class Main
public static void main(String[] args) {
ArrayList<Command> program = new ArrayList<>();
Memory.workingRegister = 0xAA;
int input1 = 0x27FF;
program.add(CommandDecoder.decode(0x3011));
program.add(CommandDecoder.decode(0x2003));
program.add(CommandDecoder.decode(0x3022));
program.add(CommandDecoder.decode(0x0008));
while(true)
{
program.get(ProgramCounter.getPc()).execute();
}
program.add(CommandDecoder.decode(input1));
Memory.setPCLATH(0xFF);
program.get(0).execute();
//ProgramCounter.incPC();
}
}

View File

@@ -1,13 +0,0 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
import de.darkress.pic16f84sim.microcontroller.Stack;
public class Return extends CommandUtils implements Command
{
@Override
public void execute()
{
ProgramCounter.setPcFrom11BitLiteral(Stack.pop());
}
}

View File

@@ -131,7 +131,8 @@ public class CommandDecoder
if (input == 0x0008)
{
return new Return();
//return();
//This is the function name. Do not mistake this for a normal return!
}
if (input == 0x0063)

View File

@@ -14,8 +14,9 @@ public class Stack
public static int pop()
{
int tmp = stack[stackPointer];
pointPrevious();
return stack[stackPointer];
return tmp;
}
public static int peek()