From a1992b6fda509a1de0269d06fa359bb0aad2a011 Mon Sep 17 00:00:00 2001 From: darkress Date: Fri, 2 Jun 2023 23:26:50 +0200 Subject: [PATCH] implemented Clrw instruction --- de/darkress/pic16f84sim/Main.java | 8 ++------ de/darkress/pic16f84sim/commands/Clrw.java | 18 ++++++++++++++++++ .../pic16f84sim/decoder/CommandDecoder.java | 3 +-- 3 files changed, 21 insertions(+), 8 deletions(-) create mode 100644 de/darkress/pic16f84sim/commands/Clrw.java diff --git a/de/darkress/pic16f84sim/Main.java b/de/darkress/pic16f84sim/Main.java index 4c38488..75b3207 100644 --- a/de/darkress/pic16f84sim/Main.java +++ b/de/darkress/pic16f84sim/Main.java @@ -12,12 +12,8 @@ class Main public static void main(String[] args) { ArrayList program = new ArrayList<>(); - int input1 = 0x27FF; - program.add(CommandDecoder.decode(0x3011)); //Write 0x11 to W - Memory.setRegister(0x14, 0xFE); - program.add(CommandDecoder.decode(0x0F94)); //Write 0x11 to W - program.add(CommandDecoder.decode(0x0F94)); //Write 0x11 to W - program.add(CommandDecoder.decode(0x0F94)); //Write 0x11 to W + Memory.workingRegister = 0x10; + program.add(CommandDecoder.decode(0x123)); //Write 0x11 to W for(int i = 0; i < program.size(); i++) { program.get(ProgramCounter.getPc()).execute(); diff --git a/de/darkress/pic16f84sim/commands/Clrw.java b/de/darkress/pic16f84sim/commands/Clrw.java new file mode 100644 index 0000000..e8661fa --- /dev/null +++ b/de/darkress/pic16f84sim/commands/Clrw.java @@ -0,0 +1,18 @@ +package de.darkress.pic16f84sim.commands; + +import de.darkress.pic16f84sim.microcontroller.Memory; +import de.darkress.pic16f84sim.microcontroller.ProgramCounter; + +public class Clrw extends FileRegisterCommandUtils implements Command +{ + @Override + public void execute() + { + final int result = 0; + + checkZeroBit(result); + + Memory.workingRegister = result; + ProgramCounter.incPC(); + } +} diff --git a/de/darkress/pic16f84sim/decoder/CommandDecoder.java b/de/darkress/pic16f84sim/decoder/CommandDecoder.java index 1d259f9..fee3db5 100644 --- a/de/darkress/pic16f84sim/decoder/CommandDecoder.java +++ b/de/darkress/pic16f84sim/decoder/CommandDecoder.java @@ -57,8 +57,7 @@ public class CommandDecoder //clrf(); break; case 0x100: - //clrw(); - break; + return new Clrw(); case 0x80: //movwf(); break;