From f0f61790597d5aad144ded0ee4465e4fef13047c Mon Sep 17 00:00:00 2001 From: Darkress <30271678+DarkressX@users.noreply.github.com> Date: Wed, 31 May 2023 01:43:48 +0200 Subject: [PATCH] implemented Retlw instruction --- de/darkress/pic16f84sim/commands/Retlw.java | 24 +++++++++++++++++++ de/darkress/pic16f84sim/commands/Return.java | 2 ++ .../pic16f84sim/decoder/CommandDecoder.java | 3 +-- 3 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 de/darkress/pic16f84sim/commands/Retlw.java diff --git a/de/darkress/pic16f84sim/commands/Retlw.java b/de/darkress/pic16f84sim/commands/Retlw.java new file mode 100644 index 0000000..dba9c94 --- /dev/null +++ b/de/darkress/pic16f84sim/commands/Retlw.java @@ -0,0 +1,24 @@ +package de.darkress.pic16f84sim.commands; + +import de.darkress.pic16f84sim.microcontroller.Memory; +import de.darkress.pic16f84sim.microcontroller.ProgramCounter; +import de.darkress.pic16f84sim.microcontroller.Stack; + +public class Retlw extends CommandUtils implements Command +{ + private final int literal; + + public Retlw(int input) + { + literal = input & 0x00FF; + } + + @Override + public void execute() + { + Memory.workingRegister = literal; + ProgramCounter.setPcFrom11BitLiteral(Stack.pop()); + //TODO: This may need some rework since it does not really load all 13 Bit into the PC. Only 8 Bit are + // effectively set + } +} diff --git a/de/darkress/pic16f84sim/commands/Return.java b/de/darkress/pic16f84sim/commands/Return.java index e24e3f9..8f7f630 100644 --- a/de/darkress/pic16f84sim/commands/Return.java +++ b/de/darkress/pic16f84sim/commands/Return.java @@ -9,5 +9,7 @@ public class Return extends CommandUtils implements Command public void execute() { ProgramCounter.setPcFrom11BitLiteral(Stack.pop()); + //TODO: This may need some rework since it does not really load all 13 Bit into the PC. Only 8 Bit are + // effectively set } } diff --git a/de/darkress/pic16f84sim/decoder/CommandDecoder.java b/de/darkress/pic16f84sim/decoder/CommandDecoder.java index 4c1942b..83ab994 100644 --- a/de/darkress/pic16f84sim/decoder/CommandDecoder.java +++ b/de/darkress/pic16f84sim/decoder/CommandDecoder.java @@ -110,8 +110,7 @@ public class CommandDecoder case 0x3000: return new Movlw(input); case 0x3400: - //retlw(); - break; + return new Retlw(input); } if ((input | 0x0060) == 0x0060)