init
This commit is contained in:
7
.vscode/settings.json
vendored
Normal file
7
.vscode/settings.json
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
{
|
||||
"java.project.sourcePaths": ["src"],
|
||||
"java.project.outputPath": "bin",
|
||||
"java.project.referencedLibraries": [
|
||||
"lib/**/*.jar"
|
||||
]
|
||||
}
|
||||
18
README.md
Normal file
18
README.md
Normal file
@@ -0,0 +1,18 @@
|
||||
## Getting Started
|
||||
|
||||
Welcome to the VS Code Java world. Here is a guideline to help you get started to write Java code in Visual Studio Code.
|
||||
|
||||
## Folder Structure
|
||||
|
||||
The workspace contains two folders by default, where:
|
||||
|
||||
- `src`: the folder to maintain sources
|
||||
- `lib`: the folder to maintain dependencies
|
||||
|
||||
Meanwhile, the compiled output files will be generated in the `bin` folder by default.
|
||||
|
||||
> If you want to customize the folder structure, open `.vscode/settings.json` and update the related settings there.
|
||||
|
||||
## Dependency Management
|
||||
|
||||
The `JAVA PROJECTS` view allows you to manage your dependencies. More details can be found [here](https://github.com/microsoft/vscode-java-dependency#manage-dependencies).
|
||||
Binary file not shown.
BIN
bin/Backend/BackendCommandProcessing/InformationConnecter.class
Normal file
BIN
bin/Backend/BackendCommandProcessing/InformationConnecter.class
Normal file
Binary file not shown.
BIN
bin/Backend/EepromLoader/ReadEepromFile.class
Normal file
BIN
bin/Backend/EepromLoader/ReadEepromFile.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$1.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$1.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$10.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$10.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$11.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$11.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$12.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$12.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$13.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$13.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$14.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$14.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$15.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$15.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$2.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$2.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$3.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$3.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$4.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$4.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$5.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$5.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$6.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$6.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$7.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$7.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$8.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$8.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$9.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction$9.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandAction.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandAction.class
Normal file
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/CommandDecoder.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/CommandDecoder.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/Backend/FrontendCommandProcessing/ReadFile.class
Normal file
BIN
bin/Backend/FrontendCommandProcessing/ReadFile.class
Normal file
Binary file not shown.
BIN
bin/Backend/Microcontroller/Bitmask.class
Normal file
BIN
bin/Backend/Microcontroller/Bitmask.class
Normal file
Binary file not shown.
BIN
bin/Backend/Microcontroller/EEPROM.class
Normal file
BIN
bin/Backend/Microcontroller/EEPROM.class
Normal file
Binary file not shown.
BIN
bin/Backend/Microcontroller/PIC.class
Normal file
BIN
bin/Backend/Microcontroller/PIC.class
Normal file
Binary file not shown.
BIN
bin/Backend/Microcontroller/RAM.class
Normal file
BIN
bin/Backend/Microcontroller/RAM.class
Normal file
Binary file not shown.
BIN
bin/Backend/Microcontroller/STACK.class
Normal file
BIN
bin/Backend/Microcontroller/STACK.class
Normal file
Binary file not shown.
BIN
bin/Backend/Microcontroller/WATCHDOG.class
Normal file
BIN
bin/Backend/Microcontroller/WATCHDOG.class
Normal file
Binary file not shown.
BIN
bin/Backend/Runtime/Environment.class
Normal file
BIN
bin/Backend/Runtime/Environment.class
Normal file
Binary file not shown.
BIN
bin/Backend/Runtime/Main.class
Normal file
BIN
bin/Backend/Runtime/Main.class
Normal file
Binary file not shown.
BIN
bin/Backend/Runtime/ProgramStepInformation.class
Normal file
BIN
bin/Backend/Runtime/ProgramStepInformation.class
Normal file
Binary file not shown.
BIN
bin/Backend/Runtime/TODO.class
Normal file
BIN
bin/Backend/Runtime/TODO.class
Normal file
Binary file not shown.
BIN
bin/Backend/Runtime/WATCHDOG.class
Normal file
BIN
bin/Backend/Runtime/WATCHDOG.class
Normal file
Binary file not shown.
BIN
bin/Backend/Statistics/ErrorHandling/BackendErrorCounter.class
Normal file
BIN
bin/Backend/Statistics/ErrorHandling/BackendErrorCounter.class
Normal file
Binary file not shown.
BIN
bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class
Normal file
BIN
bin/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.class
Normal file
Binary file not shown.
BIN
bin/Frontend/PIC_SIMULATOR_GUI_JAVA/Main.class
Normal file
BIN
bin/Frontend/PIC_SIMULATOR_GUI_JAVA/Main.class
Normal file
Binary file not shown.
Binary file not shown.
BIN
bin/In.class
Normal file
BIN
bin/In.class
Normal file
Binary file not shown.
BIN
bin/simulator_additional_functions.class
Normal file
BIN
bin/simulator_additional_functions.class
Normal file
Binary file not shown.
BIN
documentation/EXCEL/Bitmask done masks.xlsx
Executable file
BIN
documentation/EXCEL/Bitmask done masks.xlsx
Executable file
Binary file not shown.
BIN
documentation/EXCEL/Frontend an Backend.xlsx
Executable file
BIN
documentation/EXCEL/Frontend an Backend.xlsx
Executable file
Binary file not shown.
BIN
documentation/EXCEL/Mappe1.xlsx
Executable file
BIN
documentation/EXCEL/Mappe1.xlsx
Executable file
Binary file not shown.
BIN
documentation/PDF/Datenblatt_Mikroprozessor.pdf
Executable file
BIN
documentation/PDF/Datenblatt_Mikroprozessor.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Foliensatz_Von_Neumann_Modell_P1.pdf
Executable file
BIN
documentation/PDF/Foliensatz_Von_Neumann_Modell_P1.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Foliensatz_Von_Neumann_Modell_P2.pdf
Executable file
BIN
documentation/PDF/Foliensatz_Von_Neumann_Modell_P2.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Funktionsweise des PIC16F84.pdf
Executable file
BIN
documentation/PDF/Funktionsweise des PIC16F84.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/GUI_PicSim_Bedienungsanleitung.pdf
Executable file
BIN
documentation/PDF/GUI_PicSim_Bedienungsanleitung.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Mitschrieb Rechnerarchitekturen 01.pdf
Executable file
BIN
documentation/PDF/Mitschrieb Rechnerarchitekturen 01.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Operationsverstaerker.pdf
Executable file
BIN
documentation/PDF/Operationsverstaerker.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Rechnerarchitektur 08.04.2021.pdf
Executable file
BIN
documentation/PDF/Rechnerarchitektur 08.04.2021.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Selbststudium_Skript_20210415.pdf
Executable file
BIN
documentation/PDF/Selbststudium_Skript_20210415.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/TODOS Simulator.pdf
Executable file
BIN
documentation/PDF/TODOS Simulator.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/TestProg_PicSim_20210420.zip
Executable file
BIN
documentation/PDF/TestProg_PicSim_20210420.zip
Executable file
Binary file not shown.
BIN
documentation/PDF/Themenblatt_PIC_programmieren.pdf
Executable file
BIN
documentation/PDF/Themenblatt_PIC_programmieren.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Wichtige_Hinweise_zur_Vorlesung.pdf
Executable file
BIN
documentation/PDF/Wichtige_Hinweise_zur_Vorlesung.pdf
Executable file
Binary file not shown.
BIN
documentation/PDF/Wichtigste Datei evor.pdf
Executable file
BIN
documentation/PDF/Wichtigste Datei evor.pdf
Executable file
Binary file not shown.
18
documentation/TXT/Rechnerarchitektur.txt
Executable file
18
documentation/TXT/Rechnerarchitektur.txt
Executable file
@@ -0,0 +1,18 @@
|
||||
-Einlesen lst-Datei (15-16 Stck) (Anzahl von Befehlen)
|
||||
: Am Ende ist ein carrieage return.
|
||||
: int-Array Hex-Werte als int-Wert abspeichern
|
||||
: 6 feste Befehlsbit (Maske 3f00), 4 feste Befehlsbit (Maske 3c00), 3bit-Befehle -> 3 Unterschiedliche Maskierungen (Maske 3800)Ergebnis 2000:Call; Ergebnis 2800:GOTO
|
||||
: Codes in Excel-Tabelle und fest oder variabel einteilen
|
||||
: 14 Tage ab 25.03.2021
|
||||
|
||||
-> Pflichtenheft erstellen, Vorgehen, Oberfläche, Variablen Organisation, Bennennung RAM & EPROM
|
||||
|
||||
|
||||
|
||||
-Definieren der entsprechenden Arrays und globalen Variablen
|
||||
|
||||
-Definieren der Funktionsköpfe und Anlegen der Funktionsrümpfe
|
||||
|
||||
-Grundstruktur Switch Case
|
||||
|
||||
-Grafik gestalten visuelle Komponenten Ein- und Ausgabe
|
||||
5
documentation/TXT/Zeilen.txt
Executable file
5
documentation/TXT/Zeilen.txt
Executable file
@@ -0,0 +1,5 @@
|
||||
012345678 2021222324
|
||||
|
||||
0003 070C 0 0 0 3 8
|
||||
|
||||
11 Spaces
|
||||
BIN
documentation/WORD/Konzept.docx
Executable file
BIN
documentation/WORD/Konzept.docx
Executable file
Binary file not shown.
Binary file not shown.
BIN
documentation/actions.pdf
Executable file
BIN
documentation/actions.pdf
Executable file
Binary file not shown.
BIN
documentation/guilayout.pdf
Executable file
BIN
documentation/guilayout.pdf
Executable file
Binary file not shown.
BIN
pictures/gui_logo.png
Executable file
BIN
pictures/gui_logo.png
Executable file
Binary file not shown.
|
After Width: | Height: | Size: 107 KiB |
51
src/Backend/BackendCommandProcessing/BackendInformationTransferThread.java
Executable file
51
src/Backend/BackendCommandProcessing/BackendInformationTransferThread.java
Executable file
@@ -0,0 +1,51 @@
|
||||
package Backend.BackendCommandProcessing;
|
||||
|
||||
//package SIMULATOR;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
public class BackendInformationTransferThread extends Thread {
|
||||
|
||||
private static File fileBackendToFrontend = new File("../SIMULATOR_DAT/gui_set.dat");
|
||||
|
||||
private ConcurrentLinkedQueue<String> queue;
|
||||
|
||||
private int iSleepTime = 100;
|
||||
|
||||
public BackendInformationTransferThread(ConcurrentLinkedQueue<String> outputQueue) {
|
||||
queue = outputQueue;
|
||||
}
|
||||
|
||||
private int writeOutputFile() {
|
||||
int iSuccess = 0;
|
||||
if(!queue.isEmpty()) {
|
||||
String sPICInformation = queue.poll();
|
||||
FileWriter fw;
|
||||
try {
|
||||
fw = new FileWriter(fileBackendToFrontend);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write(sPICInformation);
|
||||
bw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
iSuccess = 1;
|
||||
}
|
||||
return iSuccess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
Thread.sleep(iSleepTime);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
writeOutputFile();
|
||||
}
|
||||
}
|
||||
}
|
||||
158
src/Backend/BackendCommandProcessing/InformationConnecter.java
Executable file
158
src/Backend/BackendCommandProcessing/InformationConnecter.java
Executable file
@@ -0,0 +1,158 @@
|
||||
package Backend.BackendCommandProcessing;
|
||||
|
||||
import Backend.Microcontroller.PIC;
|
||||
|
||||
public class InformationConnecter {
|
||||
|
||||
public String connectInformation (PIC oPic, int iActualLine, int iLastLine, int iSetBreakpoint, int iResetBreakpoint, long liRuntime, long liWatchdog) {
|
||||
|
||||
String sConnectedInformation = "";
|
||||
|
||||
for (int i = 0; i < 128; i++) {
|
||||
sConnectedInformation.concat("FREG " + i + "," + oPic.getRam().get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(false, i) + "\n");
|
||||
}
|
||||
int j = 0;
|
||||
for (int i = 128; i < 256; i++) {
|
||||
sConnectedInformation.concat("FREG " + i + "," + oPic.getRam().get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(true, j) + "\n");
|
||||
j++;
|
||||
}
|
||||
sConnectedInformation.concat("SETLINE " + iActualLine + "\n");
|
||||
if (iLastLine != iActualLine)
|
||||
{
|
||||
sConnectedInformation.concat("RESLINE " + iLastLine + "\n");
|
||||
}
|
||||
sConnectedInformation.concat("TIME " + (liRuntime / 100) + " µs\n");
|
||||
sConnectedInformation.concat("WReg " + oPic.get_WRegister() + "\n");
|
||||
sConnectedInformation.concat("PCL " + oPic.getRam().get_PCL() + "\n");
|
||||
sConnectedInformation.concat("PCLATH " + oPic.getRam().get_PCLATH() + "\n");
|
||||
sConnectedInformation.concat("PCINTERN " + oPic.getRam().get_Programcounter() + "\n");
|
||||
sConnectedInformation.concat("STATUS " + oPic.getRam().get_STATUS() + "\n");
|
||||
sConnectedInformation.concat("FSR " + oPic.getRam().get_FSR() + "\n");
|
||||
sConnectedInformation.concat("OPTION " + 1 + "\n");
|
||||
|
||||
//Statusbits
|
||||
int sC = oPic.getRam().get_Carryflag()? 1:0;
|
||||
int sDC = oPic.getRam().get_Digitcarryflag()? 1:0;
|
||||
int sZ = oPic.getRam().get_Zeroflag()? 1:0;
|
||||
int sPD = oPic.getRam().get_PowerDownFlag()? 1:0;
|
||||
int sTO = oPic.getRam().get_TimeOutFlag()? 1:0;
|
||||
int sRP0 = oPic.getRam().get_RP0Bit()? 1:0;
|
||||
int sRP1 = oPic.getRam().get_RP1Bit()? 1:0;
|
||||
int sIRP = oPic.getRam().get_Interruptflag()? 1:0;
|
||||
|
||||
//Set Statusbits in frontend.
|
||||
sConnectedInformation.concat("STATUSBIT " + 0 + ", " + sC + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 1 + ", " + sDC + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 2 + ", " + sZ + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 3 + ", " + sPD + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 4 + ", " + sTO + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 5 + ", " + sRP0 + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 6 + ", " + sRP1 + "\n");
|
||||
sConnectedInformation.concat("STATUSBIT " + 7 + ", " + sIRP + "\n");
|
||||
|
||||
//Optionbits
|
||||
int oPS0 = oPic.getRam().get_PS0()? 1:0;
|
||||
int oPS1 = oPic.getRam().get_PS1()? 1:0;
|
||||
int oPS2 = oPic.getRam().get_PS2()? 1:0;
|
||||
int oPSA = oPic.getRam().get_PSA()? 1:0;
|
||||
int oTSE = oPic.getRam().get_T0SE()? 1:0;
|
||||
int oTCS = oPic.getRam().get_T0CS()? 1:0;
|
||||
int oIEG = oPic.getRam().get_INTEDG()? 1:0;
|
||||
int oRPU = oPic.getRam().get_RBPU()? 1:0;
|
||||
|
||||
//Set Optionbits in frontend.
|
||||
sConnectedInformation.concat("OPTIONBIT " + 0 + ", " + oPS0 + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 1 + ", " + oPS1 + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 2 + ", " + oPS2 + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 3 + ", " + oPSA + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 4 + ", " + oTSE + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 5 + ", " + oTCS + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 6 + ", " + oIEG + "\n");
|
||||
sConnectedInformation.concat("OPTIONBIT " + 7 + ", " + oRPU + "\n");
|
||||
|
||||
//Intconbits
|
||||
int iRIF = oPic.getRam().get_RBIF()? 1:0;
|
||||
int iIF = oPic.getRam().get_INTF()? 1:0;
|
||||
int iTIF = oPic.getRam().get_T0IF()? 1:0;
|
||||
int iRIE = oPic.getRam().get_RBIE()? 1:0;
|
||||
int iIE = oPic.getRam().get_INTE()? 1:0;
|
||||
int iTIE = oPic.getRam().get_T0IE()? 1:0;
|
||||
int iEIE = oPic.getRam().get_EEIE()? 1:0;
|
||||
int iGIE = oPic.getRam().get_GIE()? 1:0;
|
||||
|
||||
//Set Intconbits in frontend.
|
||||
sConnectedInformation.concat("INTCONBIT " + 0 + ", " + iRIF + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 1 + ", " + iIF + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 2 + ", " + iTIF + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 3 + ", " + iRIE + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 4 + "," + iIE + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 5 + ", " + iTIE + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 6 + ", " + iEIE + "\n");
|
||||
sConnectedInformation.concat("INTCONBIT " + 7 + ", " + iGIE + "\n");
|
||||
|
||||
//TRISA in frontend is set.
|
||||
sConnectedInformation.concat("TRISA " + 0 + "," + ((oPic.getRam().get_TRISA() & 0b00000001) >> 0) + "\n"); //For better understanding
|
||||
sConnectedInformation.concat("TRISA " + 1 + "," + ((oPic.getRam().get_TRISA() & 0b00000010) >> 1) + "\n");
|
||||
sConnectedInformation.concat("TRISA " + 2 + "," + ((oPic.getRam().get_TRISA() & 0b00000100) >> 2) + "\n");
|
||||
sConnectedInformation.concat("TRISA " + 3 + "," + ((oPic.getRam().get_TRISA() & 0b00001000) >> 3) + "\n");
|
||||
sConnectedInformation.concat("TRISA " + 4 + "," + ((oPic.getRam().get_TRISA() & 0b00010000) >> 4) + "\n");
|
||||
sConnectedInformation.concat("TRISA " + 5 + "," + ((oPic.getRam().get_TRISA() & 0b00100000) >> 5) + "\n");
|
||||
sConnectedInformation.concat("TRISA " + 6 + "," + ((oPic.getRam().get_TRISA() & 0b01000000) >> 6) + "\n");
|
||||
sConnectedInformation.concat("TRISA " + 7 + "," + ((oPic.getRam().get_TRISA() & 0b10000000) >> 7) + "\n");
|
||||
|
||||
//PORTA in frontend is set.
|
||||
sConnectedInformation.concat("PORTA " + 0 + "," + ((oPic.getRam().get_PORTA() & 0b00001) >> 0) + "\n"); //For better understanding
|
||||
sConnectedInformation.concat("PORTA " + 1 + "," + ((oPic.getRam().get_PORTA() & 0b00010) >> 1) + "\n");
|
||||
sConnectedInformation.concat("PORTA " + 2 + "," + ((oPic.getRam().get_PORTA() & 0b00100) >> 2) + "\n");
|
||||
sConnectedInformation.concat("PORTA " + 3 + "," + ((oPic.getRam().get_PORTA() & 0b01000) >> 3) + "\n");
|
||||
sConnectedInformation.concat("PORTA " + 4 + "," + ((oPic.getRam().get_PORTA() & 0b10000) >> 4) + "\n");
|
||||
|
||||
//TRISB in frontend is set.
|
||||
sConnectedInformation.concat("TRISB " + 0 + "," + ((oPic.getRam().get_TRISB() & 0b00000001) >> 0) + "\n"); //For better understanding
|
||||
sConnectedInformation.concat("TRISB " + 1 + "," + ((oPic.getRam().get_TRISB() & 0b00000010) >> 1) + "\n");
|
||||
sConnectedInformation.concat("TRISB " + 2 + "," + ((oPic.getRam().get_TRISB() & 0b00000100) >> 2) + "\n");
|
||||
sConnectedInformation.concat("TRISB " + 3 + "," + ((oPic.getRam().get_TRISB() & 0b00001000) >> 3) + "\n");
|
||||
sConnectedInformation.concat("TRISB " + 4 + "," + ((oPic.getRam().get_TRISB() & 0b00010000) >> 4) + "\n");
|
||||
sConnectedInformation.concat("TRISB " + 5 + "," + ((oPic.getRam().get_TRISB() & 0b00100000) >> 5) + "\n");
|
||||
sConnectedInformation.concat("TRISB " + 6 + "," + ((oPic.getRam().get_TRISB() & 0b01000000) >> 6) + "\n");
|
||||
sConnectedInformation.concat("TRISB " + 7 + "," + ((oPic.getRam().get_TRISB() & 0b10000000) >> 7) + "\n");
|
||||
|
||||
//PORTB in frontend is set.
|
||||
sConnectedInformation.concat("PORTB " + 0 + "," + ((oPic.getRam().get_PORTB() & 0b00000001) >> 0) + "\n"); //For better understandin
|
||||
sConnectedInformation.concat("PORTB " + 1 + "," + ((oPic.getRam().get_PORTB() & 0b00000010) >> 1) + "\n");
|
||||
sConnectedInformation.concat("PORTB " + 2 + "," + ((oPic.getRam().get_PORTB() & 0b00000100) >> 2) + "\n");
|
||||
sConnectedInformation.concat("PORTB " + 3 + "," + ((oPic.getRam().get_PORTB() & 0b00001000) >> 3) + "\n");
|
||||
sConnectedInformation.concat("PORTB " + 4 + "," + ((oPic.getRam().get_PORTB() & 0b00010000) >> 4) + "\n");
|
||||
sConnectedInformation.concat("PORTB " + 5 + "," + ((oPic.getRam().get_PORTB() & 0b00100000) >> 5) + "\n");
|
||||
sConnectedInformation.concat("PORTB " + 6 + "," + ((oPic.getRam().get_PORTB() & 0b01000000) >> 6) + "\n");
|
||||
sConnectedInformation.concat("PORTB " + 7 + "," + ((oPic.getRam().get_PORTB() & 0b10000000) >> 7) + "\n");
|
||||
|
||||
//STACK in frontend is set.
|
||||
sConnectedInformation.concat("STACK " + oPic.getStack().getSTACK()[0] + ","
|
||||
+ oPic.getStack().getSTACK()[1] + ","
|
||||
+ oPic.getStack().getSTACK()[2] + ","
|
||||
+ oPic.getStack().getSTACK()[3] + ","
|
||||
+ oPic.getStack().getSTACK()[4] + ","
|
||||
+ oPic.getStack().getSTACK()[5] + ","
|
||||
+ oPic.getStack().getSTACK()[6] + ","
|
||||
+ oPic.getStack().getSTACK()[7] + "\n");
|
||||
|
||||
//TIMER0
|
||||
sConnectedInformation.concat("TIMER0 " + oPic.getRam().get_TMR0() + "\n");
|
||||
|
||||
//Watchdog in frontend is set. (Doesn't work correctly since watchdog isn't implemented correctly) TODO
|
||||
sConnectedInformation.concat("WATCHDOG " + liWatchdog + "\n");
|
||||
sConnectedInformation.concat("PRESCALER " + 1 + ":" + oPic.getRam().get_TMR0_PrescalerRate() + "\n");
|
||||
|
||||
if (iSetBreakpoint > -1)
|
||||
sConnectedInformation.concat("SETBREAK " + iSetBreakpoint + "\n");
|
||||
|
||||
if (iResetBreakpoint > -1)
|
||||
sConnectedInformation.concat("RESBREAK " + iResetBreakpoint + "\n");
|
||||
else if (iResetBreakpoint == -2) {
|
||||
sConnectedInformation.concat("RESALLBREAK"); //TODO \n if new string concated
|
||||
}
|
||||
|
||||
return sConnectedInformation;
|
||||
}
|
||||
}
|
||||
220
src/Backend/EepromLoader/ReadEepromFile.java
Executable file
220
src/Backend/EepromLoader/ReadEepromFile.java
Executable file
@@ -0,0 +1,220 @@
|
||||
package Backend.EepromLoader;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import Backend.Microcontroller.PIC;
|
||||
|
||||
public class ReadEepromFile {
|
||||
|
||||
/**
|
||||
* Get OP-Code out of String-data-array.
|
||||
* @param dataArray String-array where OP-Code is.
|
||||
* @return String-array with only OP-Code.
|
||||
*/
|
||||
public ArrayList<String> getOPCode(ArrayList<String> data) {
|
||||
|
||||
ArrayList<String> oPCode = new ArrayList<String>();
|
||||
|
||||
for (int i = 0; i < data.size(); i++) {
|
||||
//If element in dataArray at position i is null or a space, this element is not added into the new oPCode-Array.
|
||||
if (data.get(i) != null && data.get(i).charAt(0) != 32) {
|
||||
oPCode.add(data.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
return oPCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets whole data of the file.
|
||||
* @param file
|
||||
* @return ArrayList<String>
|
||||
* @throws IOException
|
||||
*/
|
||||
public ArrayList<String> getData(File file) {
|
||||
|
||||
ArrayList<String> list = new ArrayList<String>();
|
||||
try {
|
||||
FileReader fR = new FileReader(file);
|
||||
BufferedReader br = new BufferedReader(fR);
|
||||
|
||||
String sLine;
|
||||
while ((sLine = br.readLine()) != null) {
|
||||
list.add(sLine);
|
||||
}
|
||||
|
||||
br.close();
|
||||
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* Turns hex-values of an overhanded String-array into an int-array with decimal-values.
|
||||
* @param oPCode String-array
|
||||
* @return int-array
|
||||
*/
|
||||
public int[][] getOPCodeArrayCommandAsInt(ArrayList<String> oPCode) {
|
||||
int[][] aiReturnArray = new int[oPCode.size()][2];
|
||||
|
||||
for (int indexRowOPCode = 0; indexRowOPCode < oPCode.size(); indexRowOPCode++) {
|
||||
int indexOPCode = 0;
|
||||
int commandAsInt = 0;
|
||||
int memoryCount = 0;
|
||||
|
||||
//Stops if second space is reached. (After command is read.)
|
||||
while (indexOPCode < 9) {
|
||||
switch (indexOPCode) {
|
||||
case 0: {
|
||||
memoryCount = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 0, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[0]);
|
||||
}break;
|
||||
|
||||
case 1: {
|
||||
memoryCount = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 1, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[0]);
|
||||
}break;
|
||||
|
||||
case 2: {
|
||||
memoryCount = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 2, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[0]);
|
||||
}break;
|
||||
|
||||
case 3: {
|
||||
memoryCount = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 3, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[0]);
|
||||
}break;
|
||||
|
||||
case 5: {
|
||||
commandAsInt = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 5, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[1]);
|
||||
}break;
|
||||
|
||||
case 6: {
|
||||
commandAsInt = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 6, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[1]);
|
||||
}break;
|
||||
|
||||
case 7: {
|
||||
commandAsInt = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 7, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[1]);
|
||||
}break;
|
||||
|
||||
case 8: {
|
||||
commandAsInt = (getOPCodeArrayCommandAsIntSubFunction(oPCode, 8, indexRowOPCode, indexOPCode, memoryCount, commandAsInt)[1]);
|
||||
}break;
|
||||
}
|
||||
|
||||
//Increase location which will be checked by one.
|
||||
indexOPCode++;
|
||||
}
|
||||
aiReturnArray[indexRowOPCode][0] = memoryCount;
|
||||
aiReturnArray[indexRowOPCode][1] = commandAsInt;
|
||||
}
|
||||
return aiReturnArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param iCase Location of the actually checked character.
|
||||
* @param iIndexRowOPCode Actual row of oPCode.
|
||||
* @param iMemoryCount
|
||||
* @param iCommandAsInt
|
||||
* @return Int-Array with memoryCount [0] and commmandAsInt [1].
|
||||
*/
|
||||
public int[] getOPCodeArrayCommandAsIntSubFunction(ArrayList<String> oPCode, int iCase, int iIndexRowOPCode, int iIndexOPCode, int iMemoryCount, int iCommandAsInt) {
|
||||
|
||||
int[] aiCaseArray = {4096, 256, 16, 1, 0, 4096, 256, 16, 1};
|
||||
int[] aiResultArray = new int[2];
|
||||
|
||||
int iMemoryCountReturn = iMemoryCount;
|
||||
int iCommandAsIntReturn = iCommandAsInt;
|
||||
|
||||
switch (iCase) {
|
||||
//0123 0 == 4096 1 == 256 2 == 16 3 == 1
|
||||
//0(Ascii: 48) 1(49) ... 9(57) / A(Ascii: 65) B(66) ... F(70)
|
||||
//Checks first four characters of one line of the simulation-file which are hex-represented-characters(0-F)
|
||||
//These characters are converted into integer-representation to process further.
|
||||
case 0: //Fallthrough is wanted
|
||||
case 1: //Fallthrough is wanted
|
||||
case 2: //Fallthrough is wanted
|
||||
case 3: {
|
||||
//0-9
|
||||
if (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) > 47 && oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) < 58) {
|
||||
iMemoryCountReturn += (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) - 48) * aiCaseArray[iCase];
|
||||
}
|
||||
|
||||
//A-F
|
||||
else if (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) > 64 && oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) < 71) {
|
||||
iMemoryCountReturn += (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) - 55) * aiCaseArray[iCase];
|
||||
}
|
||||
|
||||
//Else
|
||||
else {
|
||||
System.out.println("Expected value between 48 and 57 or 65 and 70 but was " + oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode));
|
||||
}
|
||||
}break;
|
||||
|
||||
//Checks 5th, 6th, 7th, 8th character of one line of the simulation-file which are hex-represented-characters(0-F)
|
||||
//These characters are converted into integer-representation to process further.
|
||||
case 5: //Fallthrough is wanted
|
||||
case 6: //Fallthrough is wanted
|
||||
case 7: //Fallthrough is wanted
|
||||
case 8: {
|
||||
//0-9
|
||||
if (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) > 47 && oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) < 58) {
|
||||
iCommandAsIntReturn += (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) - 48) * aiCaseArray[iCase];
|
||||
}
|
||||
|
||||
//A-F
|
||||
else if (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) > 64 && oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) < 71) {
|
||||
iCommandAsIntReturn += (oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode) - 55) * aiCaseArray[iCase];
|
||||
}
|
||||
|
||||
//Else
|
||||
else {
|
||||
System.out.println("Expected value between 48 and 57 or 65 and 70 but was " + oPCode.get(iIndexRowOPCode).charAt(iIndexOPCode));
|
||||
}
|
||||
}break;
|
||||
}
|
||||
|
||||
aiResultArray[0] = iMemoryCountReturn;
|
||||
aiResultArray[1] = iCommandAsIntReturn;
|
||||
|
||||
return aiResultArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads file and writes instructions to EEPROM.
|
||||
* @param files String-Array with paths of files.
|
||||
* @param k index of file in String-Array "files".
|
||||
* @param oPIC of the main-function.
|
||||
*/
|
||||
public void readFileAndWriteToEEPROM(File file, PIC oPIC) {
|
||||
|
||||
//Creates String-arraylist with whole data.
|
||||
ArrayList<String> dataLines = getData(file);
|
||||
|
||||
//Creates String-arraylist with oPCode.
|
||||
ArrayList<String> oPCode = getOPCode(dataLines);
|
||||
|
||||
//Integer-array which will contain oPCode as int-values.
|
||||
//Get an twodimensional array with int-values.
|
||||
int[][] oPCodeAsInt = getOPCodeArrayCommandAsInt(oPCode);
|
||||
|
||||
//Set length of eeprom for programend.
|
||||
oPIC.getEeprom().setLengthEEPROM(oPCodeAsInt.length);
|
||||
|
||||
//asCommands are written into EEPROM
|
||||
for (int i = 0; i < oPCodeAsInt.length; i++) {
|
||||
//The adress where the command will be written in the EEPROM
|
||||
int memoryAdress = oPCodeAsInt[i][0];
|
||||
//System.out.println(memoryAdress);
|
||||
|
||||
//Command that will be written into the EEPROM
|
||||
int command = oPCodeAsInt[i][1];
|
||||
//System.out.println(command);
|
||||
|
||||
//asCommands are written into EEPROM
|
||||
oPIC.getEeprom().setElementXToValueY(memoryAdress, command);
|
||||
}
|
||||
}
|
||||
}
|
||||
393
src/Backend/FrontendCommandProcessing/CommandAction.java
Executable file
393
src/Backend/FrontendCommandProcessing/CommandAction.java
Executable file
@@ -0,0 +1,393 @@
|
||||
package Backend.FrontendCommandProcessing;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import Backend.BackendCommandProcessing.InformationConnecter;
|
||||
import Backend.EepromLoader.ReadEepromFile;
|
||||
import Backend.Runtime.Environment;
|
||||
import Backend.Microcontroller.PIC;
|
||||
|
||||
public class CommandAction {
|
||||
|
||||
int iAction;
|
||||
String sValue;
|
||||
Environment env;
|
||||
|
||||
//List with methods
|
||||
private List<Callable> actions = new ArrayList<>();
|
||||
|
||||
private InformationConnecter informationConnecter = new InformationConnecter();
|
||||
|
||||
public CommandAction(int iAction, String sValue, Environment env) {
|
||||
this.iAction = iAction;
|
||||
this.sValue = sValue;
|
||||
this.env = env;
|
||||
|
||||
actions.add(callLoadFile);//0
|
||||
actions.add(callSaveProgrammState);//1
|
||||
actions.add(callSetBreakpoint);//2
|
||||
actions.add(callTogglePortA);//3
|
||||
actions.add(callTogglePortB);//4
|
||||
actions.add(callChangeQuarz);//5
|
||||
actions.add(callToggleWatchdog);//6
|
||||
actions.add(callReset);//7
|
||||
actions.add(callStep);//8
|
||||
actions.add(callStartProgramm);//9
|
||||
actions.add(callStopProgramm);//10
|
||||
actions.add(callLoadProgrammState);//11
|
||||
actions.add(callRemoveBreakpoint);//12
|
||||
actions.add(callRemoveAllBreakpoints);//13
|
||||
|
||||
actions.add(callErrorReadFailed);//14
|
||||
}
|
||||
|
||||
public int execute() {
|
||||
int iReturn = 0;
|
||||
if (iAction > -1) {
|
||||
try {
|
||||
iReturn = (int)actions.get(iAction).call();
|
||||
} catch (Exception e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
Callable callLoadFile = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return loadFile();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callSaveProgrammState = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return saveProgrammState();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callSetBreakpoint = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return setBreakpoint();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callTogglePortA = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return togglePortA();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callTogglePortB = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return togglePortB();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callChangeQuarz = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return changeQuarz();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callToggleWatchdog = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return toggleWatchdog();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callReset = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return reset();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callStep = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return step();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callStartProgramm = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return startProgramm();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callStopProgramm = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return stopProgramm();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callLoadProgrammState = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return loadProgrammState();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callRemoveBreakpoint = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return removeBreakpoint();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callRemoveAllBreakpoints = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return removeAllBreakpoints();
|
||||
}
|
||||
};
|
||||
|
||||
Callable callErrorReadFailed = new Callable() {
|
||||
@Override
|
||||
public Object call() {
|
||||
return readFailed();
|
||||
}
|
||||
};
|
||||
|
||||
//Read file out of filepath and write it to EEPROM of oPIC.
|
||||
private int loadFile() {
|
||||
ReadEepromFile readEepromFile = new ReadEepromFile();
|
||||
env.getPIC().resetPIC();
|
||||
readEepromFile.readFileAndWriteToEEPROM(new File(sValue), env.getPIC());
|
||||
env.getMainToFrontendQueue().add(informationConnecter.connectInformation(env.getPIC(), env.getActualLine(), env.getLastLine(), -2, -2, env.getRuntime(), env.getWatchdog().getTime()));
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int saveProgrammState() {
|
||||
//TODO Logic
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int setBreakpoint() {
|
||||
env.changeListBreakpoints(Integer.parseInt(sValue), true);
|
||||
env.getMainToFrontendQueue().add(informationConnecter.connectInformation(env.getPIC(), env.getActualLine(), env.getLastLine(), Integer.parseInt(sValue), -2, env.getRuntime(), env.getWatchdog().getTime()));
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int togglePortA() {
|
||||
int iBit = Integer.parseInt(sValue.substring(0,1));
|
||||
int iValue = Integer.parseInt(sValue.substring(2, 3));
|
||||
env.getPIC().getRam().set_PORTA_Bit_X_To_Y(iBit, iValue);
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int togglePortB() {
|
||||
int iBit = Integer.parseInt(sValue.substring(0,1));
|
||||
int iValue = Integer.parseInt(sValue.substring(2, 3));
|
||||
env.getPIC().getRam().set_PORTB_Bit_X_To_Y(iBit, iValue);
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int changeQuarz() {
|
||||
//XTA(L) not implemented
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int toggleWatchdog() {
|
||||
/**
|
||||
* //WAT(CHDOG)
|
||||
if (sFileFrontendToBackendCommand.substring(9, 11).equals("ON"))
|
||||
{
|
||||
//ON
|
||||
liWorkWithWatchdog(1, 5);
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//OFF
|
||||
liWorkWithWatchdog(1, 4);
|
||||
}
|
||||
*/
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int reset() {
|
||||
/**
|
||||
* //RES(ET)
|
||||
liDifferenceTimeNano = 0;
|
||||
oPIC.resetPIC();
|
||||
//oPIC.Ram.set_OPTION(255);
|
||||
//resetLines();
|
||||
bCreateGUIFile = true;
|
||||
*/
|
||||
env.getPIC().resetPIC();
|
||||
env.getPIC().getRam().set_OPTION(255);
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int step() {
|
||||
/**
|
||||
* //STE(P)
|
||||
//System.out.println("STEP " + oPIC.Ram.get_Programcounter());
|
||||
if (oPIC.Ram.get_Programcounter() < (oPIC.Eeprom.getLengthEEPROM() - 1))
|
||||
{
|
||||
final long liTimeStart = System.nanoTime();
|
||||
|
||||
//Makes one step through the eeprom.
|
||||
bitMaskDecisionMaker(oPIC.Eeprom.getElement(oPIC.Ram.get_Programcounter()), oPIC);
|
||||
|
||||
final long timeEnd = System.nanoTime();
|
||||
|
||||
liDifferenceTimeNano += (timeEnd - liTimeStart);
|
||||
|
||||
if (!oPIC.Ram.get_T0CS())
|
||||
{
|
||||
oPIC.Ram.increment_TMR0();
|
||||
}
|
||||
|
||||
bCreateGUIFile = true;
|
||||
*/
|
||||
env.step();//step in env or set/gets
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int startProgramm() {
|
||||
/**
|
||||
* //STA(RT)
|
||||
|
||||
final long liTimeStart = System.nanoTime();
|
||||
|
||||
liWorkWithWatchdog(1, 1);
|
||||
|
||||
if ((iAccessBreakpoint(3, 0) > (-1)) && (iAccessBreakpoint(3, 0) <= (oPIC.Eeprom.getLengthEEPROM() - 1)))
|
||||
{
|
||||
while ((oPIC.Ram.get_Programcounter() < iAccessBreakpoint(3, 0)) && (cMenueSelection != 'p'))
|
||||
{
|
||||
//System.out.println("STEP " + oPIC.Ram.get_Programcounter());
|
||||
bitMaskDecisionMaker(oPIC.Eeprom.getElement(oPIC.Ram.get_Programcounter()), oPIC);
|
||||
|
||||
if (!oPIC.Ram.get_T0CS())
|
||||
{
|
||||
oPIC.Ram.increment_TMR0();
|
||||
}
|
||||
|
||||
bCreateGUIFile = true;
|
||||
}
|
||||
iAccessBreakpoint(2, 0);
|
||||
bCreateGUIFile = true;
|
||||
System.out.println(iAccessBreakpoint(3, 0));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
while ((oPIC.Ram.get_Programcounter() < ((oPIC.Eeprom.getLengthEEPROM() - 1))) && (cMenueSelection != 'p'))
|
||||
{
|
||||
//System.out.println("STEP " + oPIC.Ram.get_Programcounter());
|
||||
bitMaskDecisionMaker(oPIC.Eeprom.getElement(oPIC.Ram.get_Programcounter()), oPIC);
|
||||
|
||||
if (!oPIC.Ram.get_T0CS())
|
||||
{
|
||||
oPIC.Ram.increment_TMR0();
|
||||
}
|
||||
|
||||
bCreateGUIFile = true;
|
||||
}
|
||||
}
|
||||
|
||||
liWorkWithWatchdog(1, 2);
|
||||
final long timeEnd = System.nanoTime();
|
||||
|
||||
liDifferenceTimeNano = timeEnd - liTimeStart;
|
||||
|
||||
bCreateGUIFile = true;
|
||||
*/
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int stopProgramm() {
|
||||
/**
|
||||
* //STO(PP)
|
||||
//watchdogThread.setWatchdogStatus(3);
|
||||
cMenueSelection = 'p';
|
||||
*/
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int loadProgrammState() {
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int removeBreakpoint() {
|
||||
env.changeListBreakpoints(Integer.parseInt(sValue), false);
|
||||
//TODO sent message to thread, to change value in file
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int removeAllBreakpoints() {
|
||||
env.changeListBreakpoints(-1, false);
|
||||
return 0;
|
||||
}
|
||||
|
||||
private int readFailed() {
|
||||
System.out.println("Fehler: Lesen der Datei fehlgeschlagen.");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* //PRT( Scale) ? Prescaler is set from additional frontend.
|
||||
try
|
||||
{
|
||||
if (sFileFrontendToBackendCommand.substring(4, 5) != null)
|
||||
{
|
||||
oPIC.Ram.set_OPTION((oPIC.Ram.get_OPTION() & 11111000) | (Integer.parseInt(sFileFrontendToBackendCommand.substring(4, 5))));
|
||||
bCreateGUIFile = true;
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{}
|
||||
*/
|
||||
|
||||
/**
|
||||
* //PRW( Scale) ? Prescaler is set from additional frontend.
|
||||
try
|
||||
{
|
||||
if (sFileFrontendToBackendCommand.substring(4, 5) != null)
|
||||
{
|
||||
oPIC.Ram.set_OPTION((oPIC.Ram.get_OPTION() & 11111000) | (Integer.parseInt(sFileFrontendToBackendCommand.substring(4, 5))));
|
||||
bCreateGUIFile = true;
|
||||
}
|
||||
if (sFileFrontendToBackendCommand.substring(5, 6) != null)
|
||||
{
|
||||
oPIC.Ram.set_OPTION((oPIC.Ram.get_OPTION() & 11111000) | (Integer.parseInt(sFileFrontendToBackendCommand.substring(4, 6))));
|
||||
bCreateGUIFile = true;
|
||||
}
|
||||
if (sFileFrontendToBackendCommand.substring(6, 7) != null)
|
||||
{
|
||||
oPIC.Ram.set_OPTION((oPIC.Ram.get_OPTION() & 11111000) | (Integer.parseInt(sFileFrontendToBackendCommand.substring(4, 7))));
|
||||
bCreateGUIFile = true;
|
||||
}
|
||||
}
|
||||
catch (StringIndexOutOfBoundsException e)
|
||||
{}
|
||||
*/
|
||||
}
|
||||
122
src/Backend/FrontendCommandProcessing/CommandDecoder.java
Executable file
122
src/Backend/FrontendCommandProcessing/CommandDecoder.java
Executable file
@@ -0,0 +1,122 @@
|
||||
package Backend.FrontendCommandProcessing;
|
||||
|
||||
import java.util.regex.*;
|
||||
|
||||
import Backend.Runtime.Environment;
|
||||
|
||||
//TODO Changes at patterns have to occur at all methods!
|
||||
|
||||
/**
|
||||
* Class to decode commandstring.
|
||||
*/
|
||||
public class CommandDecoder {
|
||||
|
||||
private String sActualCommand = "";
|
||||
|
||||
public CommandDecoder(String sActualCommand) {
|
||||
this.sActualCommand = sActualCommand;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get type of command.
|
||||
* @return int representation of pattern, -1 if no pattern matches
|
||||
*/
|
||||
public int getCommandType() {
|
||||
|
||||
int iPatternMatched = 0;
|
||||
|
||||
//Read file and save line to string
|
||||
//sActualCommand = input.getActualCommand();
|
||||
|
||||
//External oparations
|
||||
Pattern loadFile = Pattern.compile("^F_\\S*$");//0
|
||||
Pattern saveProgrammState = Pattern.compile("^S_\\S*$");//1
|
||||
Pattern setBreakpoint = Pattern.compile("^BS_\\d*$");//2
|
||||
Pattern togglePortA = Pattern.compile("^PA_\\d\\s(1|0)$");//3
|
||||
Pattern togglePortB = Pattern.compile("^PB_\\d$");//4
|
||||
Pattern changeQuarz = Pattern.compile("^Q_[\\d]{1,2}$");//5
|
||||
Pattern toggleWatchdog = Pattern.compile("W_[tf]$");//6
|
||||
Pattern reset = Pattern.compile("^R_$");//7
|
||||
Pattern step = Pattern.compile("^S_$");//8
|
||||
Pattern startProgramm = Pattern.compile("^RP_$");//9
|
||||
Pattern stopProgramm = Pattern.compile("^SP_$");//10
|
||||
Pattern loadProgrammState = Pattern.compile("^L_\\S*$");//11
|
||||
Pattern removeBreakpoint = Pattern.compile("^BR_\\d*$");//12
|
||||
Pattern removeAllBreakpoint = Pattern.compile("^BRA$");//13
|
||||
|
||||
//Internal operations
|
||||
Pattern errorFileRead = Pattern.compile("ERROR FILEREAD");//14
|
||||
|
||||
Pattern[] patterns = {loadFile, saveProgrammState, setBreakpoint, togglePortA, togglePortB, changeQuarz, toggleWatchdog, reset, step,
|
||||
startProgramm, stopProgramm, loadProgrammState, removeBreakpoint, removeAllBreakpoint, errorFileRead};
|
||||
|
||||
int iNumberOfPatterns = patterns.length;
|
||||
|
||||
//Iterate through patterns and check if pattern matches to command.
|
||||
for (int i = 0; i < iNumberOfPatterns; i++) {
|
||||
Matcher matcher = patterns[i].matcher(sActualCommand);
|
||||
boolean bMatchFound = matcher.find();
|
||||
if (bMatchFound) {
|
||||
iPatternMatched = i;
|
||||
i = iNumberOfPatterns; // break loop for performance
|
||||
} else {
|
||||
iPatternMatched = -1;
|
||||
}
|
||||
}
|
||||
|
||||
return iPatternMatched;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of command
|
||||
* @return
|
||||
*/
|
||||
public String getCommandValue(int iCommandType) {
|
||||
|
||||
int iStringLen = sActualCommand.length();
|
||||
|
||||
String sValue = "";
|
||||
|
||||
switch (iCommandType) {
|
||||
//0 F_<Path>
|
||||
//1 S_<Path>
|
||||
//5 Q_<IndexNr>
|
||||
//6 W_<Boolean>
|
||||
case 0:
|
||||
case 1:
|
||||
case 5:
|
||||
case 6:
|
||||
case 11: {
|
||||
sValue = sActualCommand.substring(2, iStringLen);
|
||||
}break;
|
||||
|
||||
//2 BS_<RowNr>
|
||||
//3 PA_<PortNr>
|
||||
//4 PB_<PortNr>
|
||||
//12 BR_<RowNr>
|
||||
case 2:
|
||||
case 3:
|
||||
case 4:
|
||||
case 12: {
|
||||
sValue = sActualCommand.substring(3, iStringLen);
|
||||
}break;
|
||||
|
||||
case 13: {
|
||||
//No Value needed
|
||||
}break;
|
||||
|
||||
default: {
|
||||
sValue = "undefined";
|
||||
}break;
|
||||
}
|
||||
|
||||
return sValue;
|
||||
}
|
||||
|
||||
public int executeAction(Environment env) {
|
||||
int iAction = getCommandType();
|
||||
String sValue = getCommandValue(iAction);
|
||||
CommandAction action = new CommandAction(iAction, sValue, env);
|
||||
return action.execute();
|
||||
}
|
||||
}
|
||||
49
src/Backend/FrontendCommandProcessing/FrontendCommandProcessingThread.java
Executable file
49
src/Backend/FrontendCommandProcessing/FrontendCommandProcessingThread.java
Executable file
@@ -0,0 +1,49 @@
|
||||
package Backend.FrontendCommandProcessing;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
/**
|
||||
* Thread-class responsibility is to check every few milliseconds if fileBackendToFrontend exists and if so, then read it and send string through queue to main-thread.
|
||||
*/
|
||||
public class FrontendCommandProcessingThread extends Thread {
|
||||
|
||||
private static File fileBackendToFrontend = new File("../SIMULATOR_DAT/gui_set.dat");
|
||||
|
||||
private ConcurrentLinkedQueue<String> queue;
|
||||
|
||||
private int iSleepTime = 100;
|
||||
|
||||
ReadFile readFile = new ReadFile();
|
||||
|
||||
/**
|
||||
*
|
||||
* @param inputQueue overhanded from main-method
|
||||
*/
|
||||
public FrontendCommandProcessingThread(ConcurrentLinkedQueue<String> inputQueue) {
|
||||
queue = inputQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
* FrontendCommandProcessingThread-class responsibility is to check every few milliseconds if fileBackendToFrontend exists and if so, then read it and send string through queue to main-thread.
|
||||
*/
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
String sActualCommand = "";
|
||||
|
||||
while (true) {
|
||||
try {
|
||||
//Sleeps iSleepTime milli seconds
|
||||
Thread.sleep(iSleepTime);
|
||||
} catch(InterruptedException e) {
|
||||
System.out.println(e);
|
||||
}
|
||||
if (fileBackendToFrontend.isFile()) {
|
||||
sActualCommand = readFile.getActualCommand();
|
||||
queue.add(sActualCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
58
src/Backend/FrontendCommandProcessing/ReadFile.java
Executable file
58
src/Backend/FrontendCommandProcessing/ReadFile.java
Executable file
@@ -0,0 +1,58 @@
|
||||
package Backend.FrontendCommandProcessing;
|
||||
//package SIMULATOR;
|
||||
|
||||
import java.io.*;
|
||||
|
||||
/**
|
||||
* Class reads line out of file.
|
||||
*/
|
||||
public class ReadFile {
|
||||
|
||||
private File fileFrontendToBackend = new File("C:/Users/Windows 10/Desktop/Studium/SS_21/Rechnerarchitektur_Projekt/gui_change.dat");
|
||||
private String sActualCommand;
|
||||
|
||||
public ReadFile() {}
|
||||
|
||||
/**
|
||||
* Resets file from where data is read to new overhanded path.
|
||||
* @param fileFrontendToBackend
|
||||
*/
|
||||
public ReadFile(String fileFrontendToBackend) {
|
||||
this.fileFrontendToBackend = new File(fileFrontendToBackend);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads FrontendToBackend-file and updates (-)sActualCommand.
|
||||
* @return 1 at success, -1 at error
|
||||
*/
|
||||
private int readInputFile() {
|
||||
|
||||
int iReturn = 0;
|
||||
try {
|
||||
FileReader fileReader = new FileReader(fileFrontendToBackend);
|
||||
BufferedReader bufferedReader = new BufferedReader(fileReader);
|
||||
sActualCommand = bufferedReader.readLine();
|
||||
bufferedReader.close();
|
||||
fileFrontendToBackend.delete();
|
||||
iReturn = 1; // success
|
||||
} catch (IOException e) {
|
||||
iReturn = -1; // error
|
||||
}
|
||||
return iReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads file and returns actual command as string
|
||||
* @return command as string at success, ERROR at error
|
||||
*/
|
||||
public String getActualCommand() {
|
||||
String line = null;
|
||||
int iReadInputFile = readInputFile();
|
||||
if (iReadInputFile == 1) {
|
||||
line = sActualCommand;
|
||||
} else if (iReadInputFile == -1) {
|
||||
line = "ERROR FILEREAD";
|
||||
}
|
||||
return line;
|
||||
}
|
||||
}
|
||||
443
src/Backend/Microcontroller/Bitmask.java
Executable file
443
src/Backend/Microcontroller/Bitmask.java
Executable file
@@ -0,0 +1,443 @@
|
||||
package Backend.Microcontroller;
|
||||
|
||||
public class Bitmask {
|
||||
/**
|
||||
* Decides which PIC-command-method to call.
|
||||
* @param iCommandAsIntToMask
|
||||
* @param oPIC
|
||||
*/
|
||||
public int bitMaskDecoderAndExecuteCommand(int iCommandAsIntToMask, PIC oPIC) {
|
||||
|
||||
//Return-value will be -1 if command can't be read.
|
||||
int iDecodedCommand = -1;
|
||||
|
||||
//Command that was overhanded is written into "command"
|
||||
int iCommand = iCommandAsIntToMask;
|
||||
|
||||
//Bitmask to get the destination-bit
|
||||
int iDestinationBitBitmask = 0b00000010000000;
|
||||
//Destination-bit
|
||||
int iDestinationBit = (iDestinationBitBitmask & iCommand) >> 7;
|
||||
|
||||
//Bitmask to get the register-file-adress
|
||||
int iRegisterFileAddressBitmask = 0b00000001111111;
|
||||
//Register-file-adress
|
||||
int iRegisterFileAddress = (iRegisterFileAddressBitmask & iCommand);
|
||||
|
||||
//Bitmask to get bitaddress
|
||||
int iBitaddressBitmask = 0b00001110000000;
|
||||
//Bitaddress
|
||||
int iBitaddress = (iBitaddressBitmask & iCommand) >> 7;
|
||||
|
||||
//Bitmask to get eight last k's
|
||||
int iEightKBitmask = 0b00000011111111;
|
||||
int iEightK = (iEightKBitmask & iCommand);
|
||||
|
||||
//Bitmask to get eleven last k's
|
||||
int iElevenKBitmask = 0b00011111111111;
|
||||
int iElevenK = (iElevenKBitmask & iCommand);
|
||||
|
||||
//Bitmask to get TRIS-register TRIS instruction not used
|
||||
//int tRISRegisterBitmask = 0b000000000111;
|
||||
//int tRISRegisterAddress = (tRISRegisterBitmask & command);
|
||||
|
||||
if ((0b10000000000000 & iCommand) == 0b10000000000000) {
|
||||
//1x xxxx xxxx xxxx
|
||||
if ((0b01000000000000 & iCommand) == 0b01000000000000) {
|
||||
//11 xxxx xxxx xxxx
|
||||
if ((0b00100000000000 & iCommand) == 0b00100000000000) {
|
||||
//11 1xxx xxxx xxxx
|
||||
if ((0b00010000000000 & iCommand) == 0b00010000000000) {
|
||||
//11 11xx xxxx xxxx
|
||||
if ((0b00001000000000 & iCommand) == 0b00001000000000) {
|
||||
//11 111x xxxx xxxx
|
||||
iDecodedCommand = 22; //ADDLW
|
||||
} else {
|
||||
//11 110x xxxx xxxx
|
||||
iDecodedCommand = 33; //SUBLW
|
||||
}
|
||||
} else {
|
||||
//11 10xx xxxx xxxx
|
||||
if ((0b00001000000000 & iCommand) == 0b00001000000000) {
|
||||
//11 101x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//11 1011 xxxx xxxx
|
||||
} else {
|
||||
//11 1010 xxxx xxxx
|
||||
iDecodedCommand = 34; //XORLW
|
||||
}
|
||||
} else {
|
||||
//11 100x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//11 1001 xxxx xxxx
|
||||
iDecodedCommand = 23; //ANDLW
|
||||
} else {
|
||||
//11 1000 xxxx xxxx
|
||||
iDecodedCommand = 27; //IORLW
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//11 0xxx xxxx xxxx
|
||||
if ((0b00010000000000 & iCommand) == 0b00010000000000) {
|
||||
//11 01xx xxxx xxxx
|
||||
iDecodedCommand = 30; //RETLW
|
||||
} else {
|
||||
//11 00xx xxxx xxxx
|
||||
iDecodedCommand = 28; //MOVLW
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//10 xxxx xxxx xxxx
|
||||
if ((0b00100000000000 & iCommand) == 0b00100000000000) {
|
||||
//10 1xxx xxxx xxxx
|
||||
iDecodedCommand = 26; //GOTO
|
||||
} else {
|
||||
//10 0xxx xxxx xxxx
|
||||
iDecodedCommand = 24; //CALL
|
||||
}
|
||||
}
|
||||
} else if ((0b01000000000000 & iCommand) == 0b01000000000000) {
|
||||
//01 xxxx xxxx xxxx
|
||||
if ((0b00100000000000 & iCommand) == 0b00100000000000) {
|
||||
//01 1xxx xxxx xxxx
|
||||
if ((0b00010000000000 & iCommand) == 0b00010000000000) {
|
||||
//01 11xx xxxx xxxx
|
||||
iDecodedCommand = 21; //BTFSS
|
||||
} else {
|
||||
//01 10xx xxxx xxxx
|
||||
iDecodedCommand = 20; //BTFSC
|
||||
}
|
||||
} else {
|
||||
//01 0xxx xxxx xxxx
|
||||
if ((0b00010000000000 & iCommand) == 0b00010000000000) {
|
||||
//01 01xx xxxx xxxx
|
||||
iDecodedCommand = 19; //BSF
|
||||
} else {
|
||||
//01 00xx xxxx xxxx
|
||||
iDecodedCommand = 18; //BCF
|
||||
}
|
||||
}
|
||||
} else if ((0b00100000000000 & iCommand) == 0b00100000000000) {
|
||||
//00 1xxx xxxx xxxx
|
||||
if ((0b00010000000000 & iCommand) == 0b00010000000000) {
|
||||
//00 11xx xxxx xxxx
|
||||
if ((0b00001000000000 & iCommand) == 0b00001000000000) {
|
||||
//00 111x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 1111 xxxx xxxx
|
||||
iDecodedCommand = 8; //INCFSZ
|
||||
} else {
|
||||
//00 1110 xxxx xxxx
|
||||
iDecodedCommand = 16; //SWAPF
|
||||
}
|
||||
} else {
|
||||
//00 110x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 1101 xxxx xxxx
|
||||
iDecodedCommand = 13; //RLF
|
||||
} else {
|
||||
//00 1100 xxxx xxxx
|
||||
iDecodedCommand = 14; //RRF
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//00 10xx xxxx xxxx
|
||||
if ((0b00001000000000 & iCommand) == 0b00001000000000) {
|
||||
//00 101x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 1011 xxxx xxxx
|
||||
iDecodedCommand = 6; //DECFSZ
|
||||
} else {
|
||||
//00 1010 xxxx xxxx
|
||||
iDecodedCommand = 7; //INCF
|
||||
}
|
||||
} else {
|
||||
//00 100x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 1001 xxxx xxxx
|
||||
iDecodedCommand = 4; //COMF
|
||||
} else {
|
||||
//00 1000 xxxx xxxx
|
||||
iDecodedCommand = 10; //MOVF
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ((0b00010000000000 & iCommand) == 0b00010000000000) {
|
||||
//00 01xx xxxx xxxx
|
||||
if ((0b00001000000000 & iCommand) == 0b00001000000000) {
|
||||
//00 011x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 0111 xxxx xxxx
|
||||
iDecodedCommand = 0; //ADDWF
|
||||
} else {
|
||||
//00 0110 xxxx xxxx
|
||||
iDecodedCommand = 17; //XORWF
|
||||
}
|
||||
} else {
|
||||
//00 010x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 0101 xxxx xxxx
|
||||
iDecodedCommand = 1; //ANDWF
|
||||
} else {
|
||||
//00 0100 xxxx xxxx
|
||||
iDecodedCommand = 9; //IORWF
|
||||
}
|
||||
}
|
||||
} else if ((0b00001000000000 & iCommand) == 0b00001000000000) {
|
||||
//00 001x xxxx xxxx
|
||||
if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 0011 xxxx xxxx
|
||||
iDecodedCommand = 5; //DECF
|
||||
} else {
|
||||
//00 0010 xxxx xxxx
|
||||
iDecodedCommand = 15; //SUBWF
|
||||
}
|
||||
} else if ((0b00000100000000 & iCommand) == 0b00000100000000) {
|
||||
//00 0001 xxxx xxxx
|
||||
if ((0b00000010000000 & iCommand) == 0b00000010000000) {
|
||||
//00 0001 1xxx xxxx
|
||||
iDecodedCommand = 2; //CLRF
|
||||
} else {
|
||||
//00 0001 0xxx xxxx
|
||||
iDecodedCommand = 3; //CLRW
|
||||
}
|
||||
} else if ((0b00000001000000 & iCommand) == 0b00000001000000) {
|
||||
//00 0000 01xx xxxx
|
||||
if ((0b00000000100000 & iCommand) == 0b00000000100000) {
|
||||
//00 0000 011x xxxx
|
||||
if ((0b00000000010000 & iCommand) == 0b00000000010000) {
|
||||
//00 0000 0111 xxxx
|
||||
} else {
|
||||
//00 0000 0110 xxxx
|
||||
if ((0b00000000001000 & iCommand) == 0b00000000001000) {
|
||||
//00 0000 0110 1xxx
|
||||
} else {
|
||||
//00 0000 0110 0xxx
|
||||
if ((0b00000000000100 & iCommand) == 0b00000000000100) {
|
||||
//00 0000 0110 01xx
|
||||
if ((0b00000000000010 & iCommand) == 0b00000000000010) {
|
||||
//00 0000 0110 011x
|
||||
} else {
|
||||
//00 0000 0110 010x
|
||||
if ((0b00000000000001 & iCommand) == 0b00000000000001) {
|
||||
//00 0000 0110 0101
|
||||
} else {
|
||||
//00 0000 0110 0100
|
||||
iDecodedCommand = 25; //CLRWDT
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//00 0000 0110 00xx
|
||||
if ((0b00000000000010 & iCommand) == 0b00000000000010) {
|
||||
//00 0000 0110 001x
|
||||
if ((0b00000000000001 & iCommand) == 0b00000000000001) {
|
||||
//00 0000 0110 0011
|
||||
iDecodedCommand = 32; //SLEEP
|
||||
} else {
|
||||
//00 0000 0110 0010
|
||||
iDecodedCommand = 35; //OPTION
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ((0b00000010000000 & iCommand) == 0b00000010000000) {
|
||||
//00 0000 1xxx xxxx
|
||||
iDecodedCommand = 11; //MOVWF
|
||||
} else if ((0b00000000001000 & iCommand) == 0b00000000001000) {
|
||||
//00 0000 0000 1xxx
|
||||
if ((0b00000000000100 & iCommand) == 0b00000000000100) {
|
||||
//00 0000 0000 11xx
|
||||
} else {
|
||||
//00 0000 0000 10xx
|
||||
if ((0b00000000000010 & iCommand) == 0b00000000000010) {
|
||||
//00 0000 0000 101x
|
||||
} else {
|
||||
//00 0000 0000 100x
|
||||
if ((0b00000000000001 & iCommand) == 0b00000000000001) {
|
||||
//00 0000 0000 1001
|
||||
iDecodedCommand = 29; //RETFIE
|
||||
} else {
|
||||
//00 0000 0000 1000
|
||||
iDecodedCommand = 31; //RETURN
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ((0b00000001100000 & iCommand) == iCommand) {
|
||||
//00 0000 0xx0 0000
|
||||
iDecodedCommand = 12; //NOP
|
||||
}
|
||||
iDecodedCommandDecissionMaker(iDecodedCommand, oPIC, iDestinationBit, iRegisterFileAddress, iBitaddress, iEightK, iElevenK);
|
||||
|
||||
return iDecodedCommand;
|
||||
}
|
||||
|
||||
public void iDecodedCommandDecissionMaker(int iDecodedCommand, PIC oPIC, int iDestinationBit, int iRegisterFileAddress, int iBitaddress, int iEightK, int iElevenK) {
|
||||
switch (iDecodedCommand) {
|
||||
case -1: {
|
||||
System.out.println("Command doesn't exist.");
|
||||
}break;
|
||||
|
||||
case 0: {
|
||||
oPIC.ADDWF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 1: {
|
||||
oPIC.ANDWF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 2: {
|
||||
oPIC.CLRF(iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 3: {
|
||||
oPIC.CLRW();
|
||||
}break;
|
||||
|
||||
case 4: {
|
||||
oPIC.COMF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 5: {
|
||||
oPIC.DECF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 6: {
|
||||
oPIC.DECFSZ(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 7: {
|
||||
oPIC.INCF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 8: {
|
||||
oPIC.INCFSZ(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 9: {
|
||||
oPIC.IORWF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 10: {
|
||||
oPIC.MOVF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 11: {
|
||||
oPIC.MOVWF(iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 12: {
|
||||
oPIC.NOP();
|
||||
}break;
|
||||
|
||||
case 13: {
|
||||
oPIC.RLF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 14: {
|
||||
oPIC.RRF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 15: {
|
||||
oPIC.SUBWF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 16: {
|
||||
oPIC.SWAPF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 17: {
|
||||
oPIC.XORWF(iDestinationBit, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 18: {
|
||||
oPIC.BCF(iBitaddress, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 19: {
|
||||
oPIC.BSF(iBitaddress, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 20: {
|
||||
oPIC.BTFSC(iBitaddress, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 21: {
|
||||
oPIC.BTFSS(iBitaddress, iRegisterFileAddress);
|
||||
}break;
|
||||
|
||||
case 22: {
|
||||
oPIC.ADDLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 23: {
|
||||
oPIC.ANDLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 24: {
|
||||
oPIC.CALL(iElevenK);
|
||||
}break;
|
||||
|
||||
case 25: {
|
||||
//watchdogThread.setTime(0);
|
||||
oPIC.CLRWDT();
|
||||
}break;
|
||||
|
||||
case 26: {
|
||||
oPIC.GOTO(iElevenK);
|
||||
}break;
|
||||
|
||||
case 27: {
|
||||
oPIC.IORLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 28: {
|
||||
oPIC.MOVLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 29: {
|
||||
oPIC.RETFIE();
|
||||
}break;
|
||||
|
||||
case 30: {
|
||||
oPIC.RETLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 31: {
|
||||
oPIC.RETURN();
|
||||
}break;
|
||||
|
||||
case 32: {
|
||||
oPIC.SLEEP();
|
||||
}break;
|
||||
|
||||
case 33: {
|
||||
oPIC.SUBLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 34: {
|
||||
oPIC.XORLW(iEightK);
|
||||
}break;
|
||||
|
||||
case 35: {
|
||||
/**
|
||||
* To maintain upward compatibility
|
||||
* with future PIC16CXX products,
|
||||
* do not use this instruction.
|
||||
*/
|
||||
oPIC.OPTION();
|
||||
}break;
|
||||
|
||||
case 36: {
|
||||
/**
|
||||
* To maintain upward compatibility
|
||||
* with future PIC16CXX products,
|
||||
* do not use this instruction.
|
||||
*/
|
||||
oPIC.TRIS();
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
72
src/Backend/Microcontroller/EEPROM.java
Executable file
72
src/Backend/Microcontroller/EEPROM.java
Executable file
@@ -0,0 +1,72 @@
|
||||
package Backend.Microcontroller;
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 23.06.2021
|
||||
*/
|
||||
|
||||
/**
|
||||
* Electrical Eraseable Programmable Read Only Memory of the PIC (Programmspeicher)
|
||||
*/
|
||||
public class EEPROM
|
||||
{
|
||||
private int[] eeprom;
|
||||
private int eepromLength = 0;
|
||||
|
||||
public EEPROM()
|
||||
{
|
||||
eeprom = new int[1024];
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns element of index element in eeprom-array.
|
||||
* @param element index of array.
|
||||
* @return element at index.
|
||||
*/
|
||||
public int getElement(int index)
|
||||
{
|
||||
int returnValue = -1;
|
||||
|
||||
if (index >= 0 && index <= 1024)
|
||||
{
|
||||
returnValue = eeprom[index];
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns length of EEPROM
|
||||
*/
|
||||
public int getLengthEEPROM()
|
||||
{
|
||||
return eepromLength;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set element to value.
|
||||
* @param index of element.
|
||||
* @param value of what the element is set to.
|
||||
* @return true if set worked.
|
||||
*/
|
||||
public boolean setElementXToValueY(int index, int value)
|
||||
{
|
||||
boolean setWorked = false;
|
||||
|
||||
if ((index >= 0) && (index <= 1024))
|
||||
{
|
||||
eeprom[index] = value;
|
||||
setWorked = true;
|
||||
}
|
||||
|
||||
return setWorked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Length of eeprom gets restricted.
|
||||
* @param length is new length.
|
||||
*/
|
||||
public void setLengthEEPROM(int length)
|
||||
{
|
||||
eepromLength = length;
|
||||
}
|
||||
}
|
||||
1483
src/Backend/Microcontroller/PIC.java
Executable file
1483
src/Backend/Microcontroller/PIC.java
Executable file
File diff suppressed because it is too large
Load Diff
1738
src/Backend/Microcontroller/RAM.java
Executable file
1738
src/Backend/Microcontroller/RAM.java
Executable file
File diff suppressed because it is too large
Load Diff
104
src/Backend/Microcontroller/STACK.java
Executable file
104
src/Backend/Microcontroller/STACK.java
Executable file
@@ -0,0 +1,104 @@
|
||||
package Backend.Microcontroller;
|
||||
|
||||
import java.util.EmptyStackException;
|
||||
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 31.03.2021
|
||||
*/
|
||||
|
||||
/**
|
||||
* Datasheet Page 18
|
||||
*/
|
||||
public class STACK
|
||||
{
|
||||
private int stackpointer;
|
||||
private int[] stack;
|
||||
|
||||
/**
|
||||
* Constructor of STACK.
|
||||
*/
|
||||
public STACK() //
|
||||
{
|
||||
stackpointer = 0;
|
||||
//Initialize stack with -1 to decide wether the stack is empty or not, because 0 could be a return address.
|
||||
stack = new int[]{-1, -1, -1, -1, -1, -1, -1, -1};
|
||||
}
|
||||
|
||||
/**
|
||||
* Pushs returnAddress on stack. If stack is full, throws StackOverflowError.
|
||||
* @param return_Adress
|
||||
*/
|
||||
public void pushReturnAdressOnStack(int return_Adress)
|
||||
{
|
||||
if (stackpointer < 7)
|
||||
{
|
||||
stack[stackpointer] = return_Adress;
|
||||
stackpointer++;
|
||||
}
|
||||
|
||||
if (stackpointer == 7)
|
||||
{
|
||||
throw new StackOverflowError();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Pops returnAddress from stack. If stack is empty, throws EmptyStackException.
|
||||
* @return
|
||||
*/
|
||||
public int popReturnAdressFromStack()
|
||||
{
|
||||
int adressToReturn = -1;
|
||||
|
||||
if (noObjects(stack))
|
||||
{
|
||||
throw new EmptyStackException();
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
stackpointer--;
|
||||
adressToReturn = stack[stackpointer];
|
||||
stack[stackpointer] = -1;
|
||||
}
|
||||
|
||||
return adressToReturn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns stack-array.
|
||||
*/
|
||||
public int[] getSTACK()
|
||||
{
|
||||
return this.stack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns stackpointer.
|
||||
*/
|
||||
public int getStackpointer()
|
||||
{
|
||||
return stackpointer;
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if there are any objects in stack.
|
||||
* @param array to check.
|
||||
* @return true if empty, false if not empty.
|
||||
*/
|
||||
private boolean noObjects(int[] array)
|
||||
{
|
||||
boolean noObjects = true;
|
||||
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
if (stack[i] != (-1))
|
||||
{
|
||||
noObjects = false;
|
||||
}
|
||||
}
|
||||
|
||||
return noObjects;
|
||||
}
|
||||
}
|
||||
105
src/Backend/Microcontroller/WATCHDOG.java
Executable file
105
src/Backend/Microcontroller/WATCHDOG.java
Executable file
@@ -0,0 +1,105 @@
|
||||
package Backend.Microcontroller;
|
||||
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 23.06.2021
|
||||
* @lastchange 23.06.2021
|
||||
*/
|
||||
|
||||
//Doesn't work correctly, status is changed too fast.
|
||||
public class WATCHDOG extends Thread
|
||||
{
|
||||
private long time;
|
||||
private int watchdogStatus;
|
||||
private long timeStart;
|
||||
private long timeEnd;
|
||||
|
||||
/**
|
||||
* Constructor of watchdog.
|
||||
*/
|
||||
public WATCHDOG()
|
||||
{
|
||||
time = 0;
|
||||
watchdogStatus = 0;
|
||||
timeStart = 0;
|
||||
timeEnd = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return time in microseconds of watchdog.
|
||||
*/
|
||||
public synchronized long getTime()
|
||||
{
|
||||
return this.time / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets time of watchdog.
|
||||
* @param value of new time.
|
||||
*/
|
||||
public synchronized void setTime(long value)
|
||||
{
|
||||
this.time = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Status of watchdog.
|
||||
* 0: Waiting for start
|
||||
* 1: Start Watchdog
|
||||
* 2: GetTime Watchdog
|
||||
* 3: End Watchdog
|
||||
* 4: Stop Watchdog
|
||||
*/
|
||||
public synchronized int getWatchdogStatus()
|
||||
{
|
||||
return this.watchdogStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* 0: Waiting for start
|
||||
* 1: Start Watchdog
|
||||
* 2: GetTime Watchdog
|
||||
* 3: End Watchdog
|
||||
* 4: Stop Watchdog
|
||||
* @param value
|
||||
*/
|
||||
public synchronized void setWatchdogStatus(int value)
|
||||
{
|
||||
this.watchdogStatus = value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes it possible to create a thread of watchdog.
|
||||
*/
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
//If status is changed to 3, watchdog is stopped.
|
||||
while (this.watchdogStatus != 3)
|
||||
{
|
||||
if (watchdogStatus != 4)
|
||||
{
|
||||
//If status changes to 1, starts to count time and sets status to 4.
|
||||
if (this.watchdogStatus == 1)
|
||||
{
|
||||
this.timeStart = System.nanoTime();
|
||||
if (this.getWatchdogStatus() != 2)
|
||||
{
|
||||
this.setWatchdogStatus(4);
|
||||
}
|
||||
}
|
||||
|
||||
//If status changes to 2, stops count time and sets time to new value, then sets status to 4.
|
||||
if (this.watchdogStatus == 2)
|
||||
{
|
||||
this.timeEnd = System.nanoTime();
|
||||
if (this.getWatchdogStatus() != 1)
|
||||
{
|
||||
this.setWatchdogStatus(4);
|
||||
}
|
||||
this.setTime(this.timeEnd - this.timeStart);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
177
src/Backend/Runtime/Environment.java
Executable file
177
src/Backend/Runtime/Environment.java
Executable file
@@ -0,0 +1,177 @@
|
||||
/**
|
||||
* @author Aaron Moser
|
||||
* @date 21.02.2022
|
||||
* @lastchange 21.02.2022
|
||||
*/
|
||||
|
||||
package Backend.Runtime;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import Backend.BackendCommandProcessing.BackendInformationTransferThread;
|
||||
import Backend.BackendCommandProcessing.InformationConnecter;
|
||||
import Backend.FrontendCommandProcessing.CommandDecoder;
|
||||
import Backend.FrontendCommandProcessing.FrontendCommandProcessingThread;
|
||||
import Backend.Microcontroller.PIC;
|
||||
import Backend.Microcontroller.WATCHDOG;
|
||||
|
||||
public class Environment {
|
||||
|
||||
private PIC oPIC;
|
||||
|
||||
private String sEepromDataFile;
|
||||
private String sActualCommand;
|
||||
|
||||
private int iEnvironmentState;
|
||||
private int iActualLine;
|
||||
private int iLastLine;
|
||||
|
||||
private ArrayList<Integer> listBreakpoints = new ArrayList<Integer>();
|
||||
|
||||
private long liRuntime;
|
||||
|
||||
private ConcurrentLinkedQueue<String> frontendToMainQueue;
|
||||
private ConcurrentLinkedQueue<String> mainToFrontendQueue;
|
||||
|
||||
private WATCHDOG watchdog;
|
||||
|
||||
public Environment() {
|
||||
|
||||
frontendToMainQueue = new ConcurrentLinkedQueue<String>();
|
||||
mainToFrontendQueue = new ConcurrentLinkedQueue<String>();
|
||||
|
||||
FrontendCommandProcessingThread frontendCommandProcessingThread = new FrontendCommandProcessingThread(frontendToMainQueue);
|
||||
BackendInformationTransferThread backendInformationTransferThread = new BackendInformationTransferThread(mainToFrontendQueue);
|
||||
|
||||
InformationConnecter informationConnecter = new InformationConnecter();
|
||||
|
||||
watchdog = new WATCHDOG();
|
||||
|
||||
CommandDecoder commandDecoder;
|
||||
|
||||
oPIC = new PIC();
|
||||
|
||||
sEepromDataFile = "";
|
||||
sActualCommand = "";
|
||||
|
||||
//Start Threads
|
||||
frontendCommandProcessingThread.start();
|
||||
backendInformationTransferThread.start();
|
||||
|
||||
iEnvironmentState = 0;
|
||||
|
||||
while (iEnvironmentState > -1) {
|
||||
//Check if frontend sent new command.
|
||||
if (!frontendToMainQueue.isEmpty()) {
|
||||
sActualCommand = frontendToMainQueue.poll();
|
||||
commandDecoder = new CommandDecoder(sActualCommand);
|
||||
commandDecoder.executeAction(this);
|
||||
}
|
||||
|
||||
// loadfile command readEepromFile.readFileAndWriteToEEPROM(new File(sEepromDataFile), oPIC);
|
||||
}
|
||||
|
||||
//Stop Threads
|
||||
try {
|
||||
frontendCommandProcessingThread.join();
|
||||
backendInformationTransferThread.join();
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public PIC getPIC() {
|
||||
return oPIC;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> getBreakpoints() {
|
||||
return listBreakpoints;
|
||||
}
|
||||
|
||||
public ConcurrentLinkedQueue<String> getMainToFrontendQueue() {
|
||||
return mainToFrontendQueue;
|
||||
}
|
||||
|
||||
public ConcurrentLinkedQueue<String> getFrontendToMainQueue() {
|
||||
return frontendToMainQueue;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param iBreakpoint
|
||||
* @param bState
|
||||
*/
|
||||
public void changeListBreakpoints(int iBreakpoint, boolean bState) {
|
||||
if (iBreakpoint > -1) {
|
||||
if (bState) {
|
||||
//add new breakpoint to list
|
||||
boolean bExists = false;
|
||||
for (int i = 0; i < listBreakpoints.size(); i++) {
|
||||
if (listBreakpoints.get(i) == iBreakpoint)
|
||||
bExists = true;
|
||||
}
|
||||
if (!bExists) {
|
||||
listBreakpoints.add(iBreakpoint);
|
||||
}
|
||||
} else {
|
||||
//remove breakpoint from list
|
||||
int iIndex = -1;
|
||||
for (int i = 0; i < listBreakpoints.size(); i++) {
|
||||
if (listBreakpoints.get(i) == iBreakpoint) {
|
||||
iIndex = i;
|
||||
i = listBreakpoints.size();
|
||||
}
|
||||
}
|
||||
if (iIndex > -1) {
|
||||
listBreakpoints.remove(iIndex);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//remove all breakpoints from list
|
||||
while (listBreakpoints.size() > 0) {
|
||||
listBreakpoints.remove(0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getActualLine() {
|
||||
return iActualLine;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getLastLine() {
|
||||
return iLastLine;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getRuntime() {
|
||||
return liRuntime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public WATCHDOG getWatchdog() {
|
||||
return watchdog;
|
||||
}
|
||||
|
||||
public void step() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
7
src/Backend/Runtime/Main.java
Executable file
7
src/Backend/Runtime/Main.java
Executable file
@@ -0,0 +1,7 @@
|
||||
package Backend.Runtime;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
Environment env = new Environment();
|
||||
}
|
||||
}
|
||||
7
src/Backend/Runtime/ProgramStepInformation.java
Executable file
7
src/Backend/Runtime/ProgramStepInformation.java
Executable file
@@ -0,0 +1,7 @@
|
||||
package Backend.Runtime;
|
||||
|
||||
import Backend.Microcontroller.PIC;
|
||||
|
||||
public class ProgramStepInformation {
|
||||
private PIC oPIC;
|
||||
}
|
||||
98
src/Backend/Runtime/TODO.java
Executable file
98
src/Backend/Runtime/TODO.java
Executable file
@@ -0,0 +1,98 @@
|
||||
package Backend.Runtime;
|
||||
|
||||
public class TODO {
|
||||
|
||||
/**
|
||||
* Returns the actual line which represents the actual programstep.
|
||||
* @return
|
||||
|
||||
public static int iGetLine()
|
||||
{
|
||||
int iActualLine = 1;
|
||||
|
||||
if (sLoadedSimulationFile != ("Uninitialized"))
|
||||
{
|
||||
String[] asDataLines = {};
|
||||
try
|
||||
{
|
||||
//Filereader reads data out of destination.
|
||||
FileReader fR = new FileReader(new File(sLoadedSimulationFile));
|
||||
|
||||
//Creates String-array with whole data.
|
||||
asDataLines = getData(fR);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
|
||||
for (int i = 0; i < asDataLines.length; i++)
|
||||
{
|
||||
//Substring 0-4 from hex to dec. after that dec value has to be equal to progcounter minus 1 and at substring 20-25 is line.
|
||||
|
||||
String substringHexStep = "0000";
|
||||
int hexStepAsInt = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if (!((asDataLines[i].substring(0, 4)).equals(" ")))
|
||||
{
|
||||
substringHexStep = asDataLines[i].substring(0, 4);
|
||||
hexStepAsInt = Integer.parseInt(substringHexStep, 16);
|
||||
}
|
||||
}catch(NullPointerException npe){}
|
||||
|
||||
if (hexStepAsInt == (oPIC.getRam().get_Programcounter()))
|
||||
{
|
||||
iActualLine = i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return iActualLine;
|
||||
}
|
||||
|
||||
|
||||
* Returns the last line which represents the last programstep.
|
||||
* @return
|
||||
|
||||
public static int getLastLine()
|
||||
{
|
||||
int actualLine = 1;
|
||||
|
||||
if (sLoadedSimulationFile != ("Uninitialized"))
|
||||
{
|
||||
String[] dataLines = {};
|
||||
try
|
||||
{
|
||||
//Filereader reads data out of destination.
|
||||
FileReader fR = new FileReader(new File(sLoadedSimulationFile));
|
||||
|
||||
//Creates String-array with whole data.
|
||||
dataLines = getData(fR);
|
||||
}
|
||||
catch (Exception e) {}
|
||||
|
||||
for (int i = 0; i < dataLines.length; i++)
|
||||
{
|
||||
//Substring 0-4 from hex to dec. after that dec value has to be equal to progcounter minus 1 and at substring 20-25 is line.
|
||||
|
||||
String substringHexStep = "0000";
|
||||
int hexStepAsInt = 0;
|
||||
|
||||
try
|
||||
{
|
||||
if (!((dataLines[i].substring(0, 4)).equals(" ")))
|
||||
{
|
||||
substringHexStep = dataLines[i].substring(0, 4);
|
||||
hexStepAsInt = Integer.parseInt(substringHexStep, 16);
|
||||
}
|
||||
}catch(NullPointerException npe){}
|
||||
|
||||
if (hexStepAsInt == (oPIC.getRam().get_LastProgramcounter()))
|
||||
{
|
||||
actualLine = i+1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return actualLine;
|
||||
}*/
|
||||
}
|
||||
5
src/Backend/Runtime/WATCHDOG.java
Normal file
5
src/Backend/Runtime/WATCHDOG.java
Normal file
@@ -0,0 +1,5 @@
|
||||
package Backend.Runtime;
|
||||
|
||||
public enum WATCHDOG {
|
||||
|
||||
}
|
||||
16
src/Backend/Statistics/ErrorHandling/BackendErrorCounter.java
Executable file
16
src/Backend/Statistics/ErrorHandling/BackendErrorCounter.java
Executable file
@@ -0,0 +1,16 @@
|
||||
package Backend.Statistics.ErrorHandling;
|
||||
|
||||
public class BackendErrorCounter {
|
||||
private int iErrorCounter = 0;
|
||||
private int [] aiErrors;
|
||||
|
||||
public void incrementErrorCounter() {
|
||||
iErrorCounter++;
|
||||
}
|
||||
|
||||
public int getErrorCounter() {
|
||||
return iErrorCounter;
|
||||
}
|
||||
|
||||
//TODO detailed error counts
|
||||
}
|
||||
51
src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java
Executable file
51
src/Frontend/PIC_SIMULATOR_GUI_JAVA/GUIMainFrame.java
Executable file
@@ -0,0 +1,51 @@
|
||||
package Frontend.PIC_SIMULATOR_GUI_JAVA;
|
||||
|
||||
import java.awt.Color;
|
||||
import java.awt.Font;
|
||||
import java.util.ArrayList;
|
||||
|
||||
import javax.swing.BorderFactory;
|
||||
import javax.swing.ImageIcon;
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.border.Border;
|
||||
|
||||
public class GUIMainFrame extends JFrame {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public GUIMainFrame() {
|
||||
|
||||
this.setTitle("PIC-Simulator GUI"); // sets title of frame
|
||||
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // if x is pressed, exit application (HIDE_ON_CLOSE-hides application, DO_NOTHING_ON_CLOSE-prevents user from closing application)
|
||||
//this.setResizable(false); // prevent frame from beeing resized
|
||||
this.setSize(420, 420); //sets x and y dimension of frame
|
||||
this.setVisible(true); //make frame visible
|
||||
|
||||
ImageIcon guiLogo = new ImageIcon("./images/gui_logo.png"); // create an ImageIcon
|
||||
this.setIconImage(guiLogo.getImage()); // change icon of frame
|
||||
|
||||
Color guiBackgroundColor = new Color(255, 255, 255); // 0xFFFFFF || 0, 0, 0
|
||||
//this.getContentPane().setBackground(guiBackgroundColor); //change color of background
|
||||
|
||||
JLabel text = new JLabel(); // create label, passing of text at constructor possible
|
||||
text.setText("Bro do you even code?"); // set text of label
|
||||
text.setIcon(guiLogo);
|
||||
text.setHorizontalTextPosition(JLabel.CENTER); //JLabel.LEFT, JLabel.CENTER, JLabel.RIGHT
|
||||
text.setVerticalTextPosition(JLabel.TOP); //JLabel.TOP, JLabel.CENTER, JLabel.BOTTOM
|
||||
text.setForeground(Color.green); // set fontcolor of text
|
||||
text.setFont(new Font("Arial", Font.ITALIC, 20)); // set fontstyle, fontformat (PLAIN, BOLD, ITALIC), and size
|
||||
text.setIconTextGap(-100); // set gap of text to image
|
||||
text.setBackground(Color.BLUE); // set background color
|
||||
text.setOpaque(true); // display background color
|
||||
|
||||
Border border = BorderFactory.createLineBorder(Color.green, 3); // creates border for label, color and size of border
|
||||
|
||||
text.setBorder(border); // sets border of label to "border"
|
||||
text.setVerticalAlignment(JLabel.TOP); // vertically alligns label "text" (JLabel.TOP, JLabel.CENTER, JLabel.BOTTOM)
|
||||
text.setHorizontalAlignment(JLabel.CENTER); // horizontally aligns label "text" (JLabel.LEFT, JLabel.CENTER, JLabel.RIGHT)
|
||||
|
||||
this.add(text); // add label to frame
|
||||
}
|
||||
}
|
||||
11
src/Frontend/PIC_SIMULATOR_GUI_JAVA/Main.java
Executable file
11
src/Frontend/PIC_SIMULATOR_GUI_JAVA/Main.java
Executable file
@@ -0,0 +1,11 @@
|
||||
package Frontend.PIC_SIMULATOR_GUI_JAVA;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
|
||||
public class Main {
|
||||
public static void main(String[] args) {
|
||||
|
||||
GUIMainFrame frame = new GUIMainFrame();
|
||||
|
||||
}
|
||||
}
|
||||
12
src/Frontend/PIC_SIMULATOR_GUI_JAVA/ReadBackendToFrontendFile.java
Executable file
12
src/Frontend/PIC_SIMULATOR_GUI_JAVA/ReadBackendToFrontendFile.java
Executable file
@@ -0,0 +1,12 @@
|
||||
package Frontend.PIC_SIMULATOR_GUI_JAVA;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class ReadBackendToFrontendFile {
|
||||
File backendToFrontendFile = new File("../SIMULATOR_DAT/gui_set.dat");
|
||||
|
||||
|
||||
public ReadBackendToFrontendFile () {
|
||||
|
||||
}
|
||||
}
|
||||
346
src/In.java
Executable file
346
src/In.java
Executable file
@@ -0,0 +1,346 @@
|
||||
/*
|
||||
Copyright (C) 1999 (Jens Scheffler)
|
||||
|
||||
This program is free software; you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation; either version 2 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*/
|
||||
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
import java.math.*;
|
||||
|
||||
public class In {
|
||||
|
||||
/** Diese Klasse stellt einige einfache Methoden zum Einlesen von der Tastatur
|
||||
zur Verfügung. Es werden diverse Werte von der Tastatur eingelesen, die
|
||||
jeweils durch ein Leerzeichen, einen Tabstop oder ein Zeilenendezeichen
|
||||
getrennt sein müssen.
|
||||
@author Jens Scheffler
|
||||
@version 1.01 Spezialfassung für <I>Programmieren 1 in Java</I>
|
||||
*/
|
||||
|
||||
private In(){} // somit kann die Klasse nicht instanziiert werden!
|
||||
private static BufferedReader in =
|
||||
new BufferedReader(new InputStreamReader(System.in));
|
||||
private static StringTokenizer eingabe;
|
||||
private static String zeichenkette;
|
||||
|
||||
/** Löscht alles, was sich in der momentanen Zeile befindet.
|
||||
Das heißt es wird der Eingabe bis zum Zeilenende keine Beachtung mehr
|
||||
geschenkt
|
||||
*/
|
||||
public static void flush(){
|
||||
eingabe=null;
|
||||
}
|
||||
|
||||
/* Private Methode, die den Tokenizer fuellt. Dies ist uebrigens eine von
|
||||
zwei Methoden, die die Klasse zum Absturz bringen kann...*/
|
||||
private static void init(){
|
||||
zeichenkette=null;
|
||||
if (eingabe!=null && eingabe.hasMoreTokens()) return;
|
||||
while (eingabe==null || !eingabe.hasMoreTokens())
|
||||
eingabe=new StringTokenizer(readLine());
|
||||
}
|
||||
|
||||
/* Private Methode, die eine Fehlermeldung ausgibt */
|
||||
private static void error(Exception e,String prompt) {
|
||||
System.out.println("Eingabefehler "+e);
|
||||
System.out.println("Bitte Eingabe wiederholen...");
|
||||
System.out.print(prompt);
|
||||
}
|
||||
|
||||
/** Liest eine ganze Textzeile von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zeile.
|
||||
*/
|
||||
/* Dies ist die zweite Methode, die die Klasse zum Absturz bringen kann.*/
|
||||
public static String readLine(String prompt){
|
||||
flush();
|
||||
String erg="";
|
||||
System.out.print(prompt);
|
||||
try{
|
||||
erg=in.readLine();
|
||||
} catch(IOException e){
|
||||
System.err.println(""+e+"\n Programm abgebrochen...\n");
|
||||
//System.exit(1);
|
||||
}
|
||||
if (erg==null) {
|
||||
System.err.println("Dateiende erreicht.\nProgramm abgebrochen...\n");
|
||||
//System.exit(1);
|
||||
}
|
||||
return erg;
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>int</CODE>-Zahl von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static int readInteger(String prompt){
|
||||
int erg;
|
||||
System.out.print(prompt);
|
||||
init();
|
||||
while(true){
|
||||
try{
|
||||
erg=Integer.parseInt(eingabe.nextToken());
|
||||
} catch (NumberFormatException e) {
|
||||
error(e,prompt);init();continue;
|
||||
}
|
||||
return erg;
|
||||
}
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>long</CODE>-Zahl von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static long readLong(String prompt){
|
||||
long erg;
|
||||
System.out.print(prompt);
|
||||
init();
|
||||
while(true){
|
||||
try{
|
||||
erg=Long.parseLong(eingabe.nextToken());
|
||||
} catch (NumberFormatException e) {error(e,prompt);init();continue;}
|
||||
return erg;
|
||||
}
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>double</CODE>-Zahl von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static double readDouble(String prompt){
|
||||
double erg;
|
||||
System.out.print(prompt);
|
||||
init();
|
||||
while(true){
|
||||
try{
|
||||
erg=Double.valueOf(eingabe.nextToken()).doubleValue();
|
||||
} catch(NumberFormatException e) {error(e,prompt);init();continue;}
|
||||
return erg;
|
||||
}
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>float</CODE>-Zahl von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static float readFloat(String prompt){
|
||||
float erg;
|
||||
System.out.print(prompt);
|
||||
init();
|
||||
while(true){
|
||||
try{
|
||||
erg=Float.valueOf(eingabe.nextToken()).floatValue();
|
||||
} catch(NumberFormatException e) {error(e,prompt);init();continue;}
|
||||
return erg;
|
||||
}
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>short</CODE>-Zahl von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static short readShort(String prompt){
|
||||
short erg;
|
||||
System.out.print(prompt);
|
||||
init();
|
||||
while(true){
|
||||
try{
|
||||
erg=Short.valueOf(eingabe.nextToken()).shortValue();
|
||||
} catch(NumberFormatException e) {error(e,prompt);init();continue;}
|
||||
return erg;
|
||||
}
|
||||
}
|
||||
|
||||
/** Liest einen boolschen Wert von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return der eingelesene Wert.
|
||||
*/
|
||||
public static boolean readBoolean(String prompt){
|
||||
String try_this=readString(prompt);
|
||||
while (!try_this.equals("true") && !try_this.equals("false"))
|
||||
try_this=readString();
|
||||
return try_this.equals("true");
|
||||
}
|
||||
|
||||
/** Liest ein Textwort von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return das eingelesene Wort.
|
||||
*/
|
||||
public static String readString(String prompt){
|
||||
System.out.print(prompt);
|
||||
init();
|
||||
return eingabe.nextToken();
|
||||
}
|
||||
|
||||
/** Liest ein Zeichen von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return das eingelesene Zeichen.
|
||||
*/
|
||||
public static char readChar(String prompt){
|
||||
char erg;
|
||||
System.out.print(prompt);
|
||||
if (zeichenkette==null || zeichenkette.length()==0)
|
||||
zeichenkette=readString("");
|
||||
erg=zeichenkette.charAt(0);
|
||||
zeichenkette=(zeichenkette.length()>1)?zeichenkette.substring(1):null;
|
||||
return erg;
|
||||
}
|
||||
|
||||
/** Liest eine ganze Textzeile von der Tastatur ein.
|
||||
@return die eingelesene Zeile.
|
||||
*/
|
||||
public static String readLine(){
|
||||
return readLine("");
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>int</CODE>-Zahl von der Tastatur ein.
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static int readInteger(){
|
||||
return readInteger("");
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>int</CODE>-Zahl von der Tastatur ein.
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static int readInt(){
|
||||
return readInteger("");
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>int</CODE>-Zahl von der Tastatur ein. Soll vorher eine
|
||||
Eingabeaufforderung gemacht werden, geschieht dies durch den Parameter.
|
||||
Dieser kann jedoch auch wegfallen.
|
||||
@param prompt eine eventuelle Eingabeaufforderung
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static int readInt(String prompt){
|
||||
return readInteger(prompt);
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>long</CODE>-Zahl von der Tastatur ein.
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static long readLong(){
|
||||
return readLong("");
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>double</CODE>-Zahl von der Tastatur ein.
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static double readDouble(){
|
||||
return readDouble("");
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>short</CODE>-Zahl von der Tastatur ein.
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static short readShort(){
|
||||
return readShort("");
|
||||
}
|
||||
|
||||
/** Liest eine <CODE>float</CODE>-Zahl von der Tastatur ein.
|
||||
@return die eingelesene Zahl.
|
||||
*/
|
||||
public static float readFloat(){
|
||||
return readFloat("");
|
||||
}
|
||||
|
||||
/** Liest ein Zeichen von der Tastatur ein.
|
||||
@return das eingelesene Zeichen
|
||||
*/
|
||||
public static char readChar(){
|
||||
return readChar("");
|
||||
}
|
||||
|
||||
/** Liest ein Textwort von der Tastatur ein.
|
||||
@return das eingelesene Wort.
|
||||
*/
|
||||
public static String readString(){
|
||||
return readString("");
|
||||
}
|
||||
|
||||
/** Liest einen boolschen Wert von der Tastatur ein.
|
||||
@return das eingelesene Wort.
|
||||
*/
|
||||
public static boolean readBoolean(){
|
||||
return readBoolean("");
|
||||
}
|
||||
|
||||
/** Wandelt eine double-Zahl in einen String um.
|
||||
Bei der üblichen Umwandlung von double-Werten in einen String
|
||||
findet eine Rundung statt. So wird etwa die Zahl 0.1, obwohl intern
|
||||
nicht darstellbar, dennoch auf dem Bildschirm ausgegeben. Diese
|
||||
Methode umgeht die Rundung */
|
||||
public static String toString(double d) {
|
||||
if (Double.isInfinite(d) || Double.isNaN(d))
|
||||
return ""+d;
|
||||
return (new BigDecimal(d)).toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt den Standard-Inputreader auf neuen Eingabestrom
|
||||
* @param in inputstream instance, not null
|
||||
*/
|
||||
public static void setInputStream(InputStream in) {
|
||||
if (in == null)
|
||||
throw new IllegalArgumentException("in darf nicht null sein.");
|
||||
In.in = new BufferedReader(new InputStreamReader(in));
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt den Standard-Inputreader auf neuen Eingabestrom
|
||||
* @param in reader instance, not null
|
||||
*/
|
||||
public static void setInputStreamReader(Reader in) {
|
||||
if (in == null)
|
||||
throw new IllegalArgumentException("in darf nicht null sein.");
|
||||
|
||||
In.in = new BufferedReader(in);
|
||||
}
|
||||
|
||||
/**
|
||||
* Setzt den Standard-Inputreader auf neuen Eingabestrom
|
||||
*
|
||||
* @deprecated
|
||||
* @param bin BufferedReader
|
||||
*/
|
||||
public static void setReader (BufferedReader bin) {
|
||||
if (bin == null)
|
||||
throw new IllegalArgumentException("bin darf nicht null sein.");
|
||||
|
||||
In.in = bin;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
127
src/simulator_additional_functions.java
Executable file
127
src/simulator_additional_functions.java
Executable file
@@ -0,0 +1,127 @@
|
||||
import java.io.*;
|
||||
|
||||
//how to use In.java
|
||||
|
||||
public class simulator_additional_functions
|
||||
{
|
||||
public static char menueSelectionChar = 'A';
|
||||
public static char secondMenueSelectionChar = 'A';
|
||||
public static String secondMenueSelectionString = "";
|
||||
public static File frontendToBackendFile = new File("../SIMULATOR_DAT/gui_change.dat");
|
||||
|
||||
public static void main(String[] args)
|
||||
{
|
||||
int []array = new int[9];
|
||||
array[0] = 1;
|
||||
array[1] = 2;
|
||||
array[2] = 4;
|
||||
array[3] = 8;
|
||||
array[4] = 16;
|
||||
array[5] = 32;
|
||||
array[6] = 64;
|
||||
array[7] = 128;
|
||||
array[8] = 256;
|
||||
|
||||
while ((menueSelectionChar != 'S') && (menueSelectionChar != 's'))
|
||||
{
|
||||
menueSelectionChar = In.readChar("What do you want to do?\n(B/b)reakpoint, (P/p)rescaler, (S/s)top:");
|
||||
|
||||
switch (menueSelectionChar)
|
||||
{
|
||||
case 'B':
|
||||
case 'b':
|
||||
{
|
||||
secondMenueSelectionString = In.readString("In which line do you want to set your breakpoint?:");
|
||||
|
||||
if (!frontendToBackendFile.isFile())
|
||||
{
|
||||
if (Integer.parseInt(secondMenueSelectionString) >= 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
FileWriter fw = new FileWriter(frontendToBackendFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write("BREAKPOINT " + secondMenueSelectionString);
|
||||
bw.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
System.out.println("Please try again, value must be greater -1");
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
System.out.println("Error can't create new File, File already exists!");
|
||||
}
|
||||
}break;
|
||||
|
||||
case 'P':
|
||||
case 'p':
|
||||
{
|
||||
secondMenueSelectionChar = In.readChar("Which Prescaler you want to set? (T/t)imer0, (W/w)atchdogtimer");
|
||||
switch (secondMenueSelectionChar)
|
||||
{
|
||||
case 'T':
|
||||
case 't':
|
||||
{
|
||||
if (!frontendToBackendFile.isFile())
|
||||
{
|
||||
secondMenueSelectionChar = In.readChar("What value you want to set the prescaler?\n0. 1, 1. 2, 2. 4, 3. 8, 4. 16, 5. 32, 6. 64, 7. 128, 8. 256:");
|
||||
|
||||
if ((Integer.parseInt("" + secondMenueSelectionChar) >= 0) && (Integer.parseInt("" + secondMenueSelectionChar) < 9))
|
||||
{
|
||||
try
|
||||
{
|
||||
FileWriter fw = new FileWriter(frontendToBackendFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write("PRT " + Integer.parseInt("" + secondMenueSelectionChar));
|
||||
bw.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
System.out.println("Error can't create new File, File already exists!");
|
||||
}
|
||||
}break;
|
||||
|
||||
case 'W':
|
||||
case 'w':
|
||||
{
|
||||
if (!frontendToBackendFile.isFile())
|
||||
{
|
||||
secondMenueSelectionChar = In.readChar("What value you want to set the prescaler?\n0. 2, 1. 4, 2. 8, 3. 16, 4. 32, 5. 64, 6. 128, 7. 256:");
|
||||
|
||||
if ((Integer.parseInt("" + secondMenueSelectionChar) > 0) && (Integer.parseInt("" + secondMenueSelectionChar) < 9))
|
||||
{
|
||||
try
|
||||
{
|
||||
FileWriter fw = new FileWriter(frontendToBackendFile);
|
||||
BufferedWriter bw = new BufferedWriter(fw);
|
||||
bw.write("PRW " + array[Integer.parseInt("" + secondMenueSelectionChar)]);
|
||||
bw.close();
|
||||
}
|
||||
catch (IOException ioe)
|
||||
{}
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
System.out.println("Error can't create new File, File already exists!");
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
29
testfiles/TPicSim1.LST
Executable file
29
testfiles/TPicSim1.LST
Executable file
@@ -0,0 +1,29 @@
|
||||
00001 ;TPicSim1
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es werden alle Literal-Befehle gepr<70>ft
|
||||
00004 ;(c) St. Lehmann
|
||||
00005 ;Ersterstellung: 23.03.2016
|
||||
00006 ;19.05.2020
|
||||
00007 ;mod. 18.10.2018 Version HSO
|
||||
00008 ;
|
||||
00009 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00010
|
||||
00011
|
||||
00012 ;Definition des Prozessors
|
||||
00013 device 16F84
|
||||
00014
|
||||
00015 ;Festlegen des Codebeginns
|
||||
00016 org 0
|
||||
00017 start
|
||||
0000 3011 00018 movlw 11h ;in W steht nun 11h, Statusreg. unver<65>ndert
|
||||
0001 3930 00019 andlw 30h ;W = 10h, C=x, DC=x, Z=0
|
||||
0002 380D 00020 iorlw 0Dh ;W = 1Dh, C=x, DC=x, Z=0
|
||||
0003 3C3D 00021 sublw 3Dh ;W = 20h, C=1, DC=1, Z=0
|
||||
0004 3A20 00022 xorlw 20h ;W = 00h, C=1, DC=1, Z=1
|
||||
0005 3E25 00023 addlw 25h ;W = 25h, C=0, DC=0, Z=0
|
||||
00024
|
||||
00025
|
||||
00026 ende
|
||||
0006 2806 00027 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00028
|
||||
00029
|
||||
315
testfiles/TPicSim10.LST
Executable file
315
testfiles/TPicSim10.LST
Executable file
@@ -0,0 +1,315 @@
|
||||
00001 ;TPicSim10
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es wird die richtige Funktionsweise von PCL und PCLATH am Beispiel
|
||||
00004 ;eines Tabellenzugriffs getestet
|
||||
00005 ;(c) St. Lehmann
|
||||
00006 ;19.04.2014
|
||||
00007 ;18.10.2018 mod. f<>r HSO
|
||||
00008
|
||||
00009 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00010
|
||||
00011 ;Definition einiger Symbole
|
||||
00012 indirect equ 0
|
||||
00013 pcl equ 02h
|
||||
00014 status equ 03h
|
||||
00015 fsr equ 04h
|
||||
00016 ra equ 05h
|
||||
00017 rb equ 06h
|
||||
00018 pclath equ 0ah
|
||||
00019 intcon equ 0bh
|
||||
00020
|
||||
00021 ;Definition des Prozessors
|
||||
00022 device 16F84
|
||||
00023 ;Festlegen des Codebeginns
|
||||
00024 org 0
|
||||
00025 start
|
||||
0000 3000 00026 movlw 0 ;Index f<>r Tabellenzugriff in 0FH
|
||||
0001 008F 00027 movwf 0fh
|
||||
0002 3005 00028 movlw 5 ;insgesamt 5 Tabellenzugriffe
|
||||
0003 008E 00029 movwf 0eh
|
||||
0004 3010 00030 movlw 10h ;Ergebnis wird ab 10H abgespeichert
|
||||
0005 0084 00031 movwf fsr
|
||||
00032 loop
|
||||
0006 3001 00033 movlw 1 ;PCLATH setzen, damit auf den Bereich 256-511 zugegriffen werden kann
|
||||
0007 008A 00034 movwf pclath
|
||||
0008 080F 00035 movf 0fh,w
|
||||
0009 2109 00036 call tabelle
|
||||
000A 0080 00037 movwf indirect
|
||||
000B 0A84 00038 incf fsr
|
||||
000C 0A8F 00039 incf 0fh
|
||||
000D 0B8E 00040 decfsz 0eh
|
||||
000E 2806 00041 goto loop
|
||||
000F 018A 00042 clrf pclath
|
||||
0010 080F 00043 movf 0fh,w
|
||||
0011 2109 00044 call tabelle ;Fehler, der ADDWF PCL kommt nicht in die Tabelle. Grund: in W steht 5
|
||||
00045 ;im PC 109 bzw. nach dem Fetch 10A. Zu diesem Wert wird 5 addiert und
|
||||
00046 ;die oberen Bits auf 0 gesetzt (PCLATH=0). Damit steht im PC der Wert
|
||||
00047 ;0Fh. Dorthin springt der PIC durch den ADDWF-Befehl. Hier verweilt
|
||||
00048 ;das Programm w<>hrend der Stack immer weiter w<>chst.
|
||||
00049
|
||||
00050
|
||||
00051 ende
|
||||
0012 2812 00052 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00053
|
||||
0013 0000 00054 nop
|
||||
0014 0000 00055 nop
|
||||
0015 0000 00056 nop
|
||||
0016 0000 00057 nop
|
||||
0017 0000 00058 nop
|
||||
0018 0000 00059 nop
|
||||
0019 0000 00060 nop
|
||||
001A 0000 00061 nop
|
||||
001B 0000 00062 nop
|
||||
001C 0000 00063 nop
|
||||
001D 0000 00064 nop
|
||||
001E 0000 00065 nop
|
||||
001F 0000 00066 nop
|
||||
0020 0000 00067 nop
|
||||
0021 0000 00068 nop
|
||||
0022 0000 00069 nop
|
||||
0023 0000 00070 nop
|
||||
0024 0000 00071 nop
|
||||
0025 0000 00072 nop
|
||||
0026 0000 00073 nop
|
||||
0027 0000 00074 nop
|
||||
0028 0000 00075 nop
|
||||
0029 0000 00076 nop
|
||||
002A 0000 00077 nop
|
||||
002B 0000 00078 nop
|
||||
002C 0000 00079 nop
|
||||
002D 0000 00080 nop
|
||||
002E 0000 00081 nop
|
||||
002F 0000 00082 nop
|
||||
0030 0000 00083 nop
|
||||
0031 0000 00084 nop
|
||||
0032 0000 00085 nop
|
||||
0033 0000 00086 nop
|
||||
0034 0000 00087 nop
|
||||
0035 0000 00088 nop
|
||||
0036 0000 00089 nop
|
||||
0037 0000 00090 nop
|
||||
0038 0000 00091 nop
|
||||
0039 0000 00092 nop
|
||||
003A 0000 00093 nop
|
||||
003B 0000 00094 nop
|
||||
003C 0000 00095 nop
|
||||
003D 0000 00096 nop
|
||||
003E 0000 00097 nop
|
||||
003F 0000 00098 nop
|
||||
0040 0000 00099 nop
|
||||
0041 0000 00100 nop
|
||||
0042 0000 00101 nop
|
||||
0043 0000 00102 nop
|
||||
0044 0000 00103 nop
|
||||
0045 0000 00104 nop
|
||||
0046 0000 00105 nop
|
||||
0047 0000 00106 nop
|
||||
0048 0000 00107 nop
|
||||
0049 0000 00108 nop
|
||||
004A 0000 00109 nop
|
||||
004B 0000 00110 nop
|
||||
004C 0000 00111 nop
|
||||
004D 0000 00112 nop
|
||||
004E 0000 00113 nop
|
||||
004F 0000 00114 nop
|
||||
0050 0000 00115 nop
|
||||
0051 0000 00116 nop
|
||||
0052 0000 00117 nop
|
||||
0053 0000 00118 nop
|
||||
0054 0000 00119 nop
|
||||
0055 0000 00120 nop
|
||||
0056 0000 00121 nop
|
||||
0057 0000 00122 nop
|
||||
0058 0000 00123 nop
|
||||
0059 0000 00124 nop
|
||||
005A 0000 00125 nop
|
||||
005B 0000 00126 nop
|
||||
005C 0000 00127 nop
|
||||
005D 0000 00128 nop
|
||||
005E 0000 00129 nop
|
||||
005F 0000 00130 nop
|
||||
0060 0000 00131 nop
|
||||
0061 0000 00132 nop
|
||||
0062 0000 00133 nop
|
||||
0063 0000 00134 nop
|
||||
0064 0000 00135 nop
|
||||
0065 0000 00136 nop
|
||||
0066 0000 00137 nop
|
||||
0067 0000 00138 nop
|
||||
0068 0000 00139 nop
|
||||
0069 0000 00140 nop
|
||||
006A 0000 00141 nop
|
||||
006B 0000 00142 nop
|
||||
006C 0000 00143 nop
|
||||
006D 0000 00144 nop
|
||||
006E 0000 00145 nop
|
||||
006F 0000 00146 nop
|
||||
0070 0000 00147 nop
|
||||
0071 0000 00148 nop
|
||||
0072 0000 00149 nop
|
||||
0073 0000 00150 nop
|
||||
0074 0000 00151 nop
|
||||
0075 0000 00152 nop
|
||||
0076 0000 00153 nop
|
||||
0077 0000 00154 nop
|
||||
0078 0000 00155 nop
|
||||
0079 0000 00156 nop
|
||||
007A 0000 00157 nop
|
||||
007B 0000 00158 nop
|
||||
007C 0000 00159 nop
|
||||
007D 0000 00160 nop
|
||||
007E 0000 00161 nop
|
||||
007F 0000 00162 nop
|
||||
0080 0000 00163 nop
|
||||
0081 0000 00164 nop
|
||||
0082 0000 00165 nop
|
||||
0083 0000 00166 nop
|
||||
0084 0000 00167 nop
|
||||
0085 0000 00168 nop
|
||||
0086 0000 00169 nop
|
||||
0087 0000 00170 nop
|
||||
0088 0000 00171 nop
|
||||
0089 0000 00172 nop
|
||||
008A 0000 00173 nop
|
||||
008B 0000 00174 nop
|
||||
008C 0000 00175 nop
|
||||
008D 0000 00176 nop
|
||||
008E 0000 00177 nop
|
||||
008F 0000 00178 nop
|
||||
0090 0000 00179 nop
|
||||
0091 0000 00180 nop
|
||||
0092 0000 00181 nop
|
||||
0093 0000 00182 nop
|
||||
0094 0000 00183 nop
|
||||
0095 0000 00184 nop
|
||||
0096 0000 00185 nop
|
||||
0097 0000 00186 nop
|
||||
0098 0000 00187 nop
|
||||
0099 0000 00188 nop
|
||||
009A 0000 00189 nop
|
||||
009B 0000 00190 nop
|
||||
009C 0000 00191 nop
|
||||
009D 0000 00192 nop
|
||||
009E 0000 00193 nop
|
||||
009F 0000 00194 nop
|
||||
00A0 0000 00195 nop
|
||||
00A1 0000 00196 nop
|
||||
00A2 0000 00197 nop
|
||||
00A3 0000 00198 nop
|
||||
00A4 0000 00199 nop
|
||||
00A5 0000 00200 nop
|
||||
00A6 0000 00201 nop
|
||||
00A7 0000 00202 nop
|
||||
00A8 0000 00203 nop
|
||||
00A9 0000 00204 nop
|
||||
00AA 0000 00205 nop
|
||||
00AB 0000 00206 nop
|
||||
00AC 0000 00207 nop
|
||||
00AD 0000 00208 nop
|
||||
00AE 0000 00209 nop
|
||||
00AF 0000 00210 nop
|
||||
00B0 0000 00211 nop
|
||||
00B1 0000 00212 nop
|
||||
00B2 0000 00213 nop
|
||||
00B3 0000 00214 nop
|
||||
00B4 0000 00215 nop
|
||||
00B5 0000 00216 nop
|
||||
00B6 0000 00217 nop
|
||||
00B7 0000 00218 nop
|
||||
00B8 0000 00219 nop
|
||||
00B9 0000 00220 nop
|
||||
00BA 0000 00221 nop
|
||||
00BB 0000 00222 nop
|
||||
00BC 0000 00223 nop
|
||||
00BD 0000 00224 nop
|
||||
00BE 0000 00225 nop
|
||||
00BF 0000 00226 nop
|
||||
00C0 0000 00227 nop
|
||||
00C1 0000 00228 nop
|
||||
00C2 0000 00229 nop
|
||||
00C3 0000 00230 nop
|
||||
00C4 0000 00231 nop
|
||||
00C5 0000 00232 nop
|
||||
00C6 0000 00233 nop
|
||||
00C7 0000 00234 nop
|
||||
00C8 0000 00235 nop
|
||||
00C9 0000 00236 nop
|
||||
00CA 0000 00237 nop
|
||||
00CB 0000 00238 nop
|
||||
00CC 0000 00239 nop
|
||||
00CD 0000 00240 nop
|
||||
00CE 0000 00241 nop
|
||||
00CF 0000 00242 nop
|
||||
00D0 0000 00243 nop
|
||||
00D1 0000 00244 nop
|
||||
00D2 0000 00245 nop
|
||||
00D3 0000 00246 nop
|
||||
00D4 0000 00247 nop
|
||||
00D5 0000 00248 nop
|
||||
00D6 0000 00249 nop
|
||||
00D7 0000 00250 nop
|
||||
00D8 0000 00251 nop
|
||||
00D9 0000 00252 nop
|
||||
00DA 0000 00253 nop
|
||||
00DB 0000 00254 nop
|
||||
00DC 0000 00255 nop
|
||||
00DD 0000 00256 nop
|
||||
00DE 0000 00257 nop
|
||||
00DF 0000 00258 nop
|
||||
00E0 0000 00259 nop
|
||||
00E1 0000 00260 nop
|
||||
00E2 0000 00261 nop
|
||||
00E3 0000 00262 nop
|
||||
00E4 0000 00263 nop
|
||||
00E5 0000 00264 nop
|
||||
00E6 0000 00265 nop
|
||||
00E7 0000 00266 nop
|
||||
00E8 0000 00267 nop
|
||||
00E9 0000 00268 nop
|
||||
00EA 0000 00269 nop
|
||||
00EB 0000 00270 nop
|
||||
00EC 0000 00271 nop
|
||||
00ED 0000 00272 nop
|
||||
00EE 0000 00273 nop
|
||||
00EF 0000 00274 nop
|
||||
00F0 0000 00275 nop
|
||||
00F1 0000 00276 nop
|
||||
00F2 0000 00277 nop
|
||||
00F3 0000 00278 nop
|
||||
00F4 0000 00279 nop
|
||||
00F5 0000 00280 nop
|
||||
00F6 0000 00281 nop
|
||||
00F7 0000 00282 nop
|
||||
00F8 0000 00283 nop
|
||||
00F9 0000 00284 nop
|
||||
00FA 0000 00285 nop
|
||||
00FB 0000 00286 nop
|
||||
00FC 0000 00287 nop
|
||||
00FD 0000 00288 nop
|
||||
00FE 0000 00289 nop
|
||||
00FF 0000 00290 nop
|
||||
0100 0000 00291 nop
|
||||
0101 0000 00292 nop
|
||||
0102 0000 00293 nop
|
||||
0103 0000 00294 nop
|
||||
0104 0000 00295 nop
|
||||
0105 0000 00296 nop
|
||||
0106 0000 00297 nop
|
||||
0107 0000 00298 nop
|
||||
0108 0000 00299 nop
|
||||
00300 Tabelle
|
||||
0109 0782 00301 addwf pcl
|
||||
010A 3460 00302 retlw 60h
|
||||
010B 3461 00303 retlw 61h
|
||||
010C 3462 00304 retlw 62h
|
||||
010D 3463 00305 retlw 63h
|
||||
010E 3464 00306 retlw 64h
|
||||
010F 3465 00307 retlw 65h
|
||||
0110 3466 00308 retlw 66h
|
||||
0111 3467 00309 retlw 67h
|
||||
0112 3468 00310 retlw 68h
|
||||
0113 3469 00311 retlw 69h
|
||||
0114 346A 00312 retlw 6Ah
|
||||
00313
|
||||
00314
|
||||
00315
|
||||
71
testfiles/TPicSim101.LST
Executable file
71
testfiles/TPicSim101.LST
Executable file
@@ -0,0 +1,71 @@
|
||||
00001 ;TPicSim101
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es wird die richtige Funktionsweise von PCL und PCLATH am Beispiel
|
||||
00004 ;eines Tabellenzugriffs getestet
|
||||
00005 ;(c) St. Lehmann
|
||||
00006 ;19.04.2014
|
||||
00007 ;18.10.2018 mod. f<>r HSO es wird die Tabelle durch ein ORG 100H auf die
|
||||
00008 ; Adresse 100H gelegt.
|
||||
00009
|
||||
00010 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00011
|
||||
00012 ;Definition einiger Symbole
|
||||
00013 indirect equ 0
|
||||
00014 pcl equ 02h
|
||||
00015 status equ 03h
|
||||
00016 fsr equ 04h
|
||||
00017 ra equ 05h
|
||||
00018 rb equ 06h
|
||||
00019 pclath equ 0ah
|
||||
00020 intcon equ 0bh
|
||||
00021
|
||||
00022 ;Definition des Prozessors
|
||||
00023 device 16F84
|
||||
00024 ;Festlegen des Codebeginns
|
||||
00025 org 0
|
||||
00026 start
|
||||
0000 3000 00027 movlw 0 ;Index f<>r Tabellenzugriff in 0FH
|
||||
0001 008F 00028 movwf 0fh
|
||||
0002 3005 00029 movlw 5 ;insgesamt 5 Tabellenzugriffe
|
||||
0003 008E 00030 movwf 0eh
|
||||
0004 3010 00031 movlw 10h ;Ergebnis wird ab 10H abgespeichert
|
||||
0005 0084 00032 movwf fsr
|
||||
00033 loop
|
||||
0006 3001 00034 movlw 1 ;PCLATH setzen, damit auf den Bereich 256-511 zugegriffen werden kann
|
||||
0007 008A 00035 movwf pclath
|
||||
0008 080F 00036 movf 0fh,w
|
||||
0009 2100 00037 call tabelle
|
||||
000A 0080 00038 movwf indirect
|
||||
000B 0A84 00039 incf fsr
|
||||
000C 0A8F 00040 incf 0fh
|
||||
000D 0B8E 00041 decfsz 0eh
|
||||
000E 2806 00042 goto loop
|
||||
000F 018A 00043 clrf pclath
|
||||
0010 080F 00044 movf 0fh,w
|
||||
0011 2100 00045 call tabelle ;Fehler, der ADDWF PCL kommt nicht in die Tabelle. Grund: in W steht 5
|
||||
00046 ;im PC 109 bzw. nach dem Fetch 10A. Zu diesem Wert wird 5 addiert und
|
||||
00047 ;die oberen Bits auf 0 gesetzt (PCLATH=0). Damit steht im PC der Wert
|
||||
00048 ;0Fh. Dorthin springt der PIC durch den ADDWF-Befehl. Hier verweilt
|
||||
00049 ;das Programm w<>hrend der Stack immer weiter w<>chst.
|
||||
00050
|
||||
00051
|
||||
00052 ende
|
||||
0012 2812 00053 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00054
|
||||
00055 org 100H
|
||||
00056 Tabelle
|
||||
0100 0782 00057 addwf pcl
|
||||
0101 3460 00058 retlw 60h
|
||||
0102 3461 00059 retlw 61h
|
||||
0103 3462 00060 retlw 62h
|
||||
0104 3463 00061 retlw 63h
|
||||
0105 3464 00062 retlw 64h
|
||||
0106 3465 00063 retlw 65h
|
||||
0107 3466 00064 retlw 66h
|
||||
0108 3467 00065 retlw 67h
|
||||
0109 3468 00066 retlw 68h
|
||||
010A 3469 00067 retlw 69h
|
||||
010B 346A 00068 retlw 6Ah
|
||||
00069
|
||||
00070
|
||||
00071
|
||||
52
testfiles/TPicSim11.LST
Executable file
52
testfiles/TPicSim11.LST
Executable file
@@ -0,0 +1,52 @@
|
||||
00001 ;TPicSim11
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es wird der Watchdog mit und ohne Vorteiler gepr<70>ft
|
||||
00004 ;(c) St. Lehmann
|
||||
00005 ;19.04.2014
|
||||
00006 ;18.10.2018 mod. f<>r HSO
|
||||
00007
|
||||
00008
|
||||
00009 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00010
|
||||
00011 ;Definition einiger Symbole
|
||||
00012 indirect equ 0
|
||||
00013 status equ 03h
|
||||
00014 fsr equ 04h
|
||||
00015 ra equ 05h
|
||||
00016 rb equ 06h
|
||||
00017 count equ 0ch
|
||||
00018
|
||||
00019 ;Definition des Prozessors
|
||||
00020 device 16F84
|
||||
00021 ;Festlegen des Codebeginns
|
||||
00022 org 0
|
||||
00023 start
|
||||
00024 ;zuerst wird der VT dem Timer zugewiesen. Damit bekommt der Watchdog
|
||||
00025 ;die kleinste Zeit (ca. 18 ms) zugewiesen
|
||||
0000 3000 00026 movlw 00000000B ;Option-Register entsp. initialisieren
|
||||
0001 1683 00027 bsf status,5 ;Bank umschalten
|
||||
0002 0081 00028 movwf 1 ;Option-Register
|
||||
0003 1283 00029 bcf status,5
|
||||
0004 01A0 00030 clrf 20h
|
||||
0005 01A1 00031 clrf 21h
|
||||
0006 01A2 00032 clrf 22h
|
||||
0007 01A3 00033 clrf 23h
|
||||
00034 loop1
|
||||
0008 0FA0 00035 incfsz 20h
|
||||
0009 2808 00036 goto loop1 ;kein <20>berlauf
|
||||
000A 0FA1 00037 incfsz 21h ;n<>chste Stelle
|
||||
000B 2808 00038 goto loop1 ;kein <20>berlauf
|
||||
000C 0FA2 00039 incfsz 22h ;ja
|
||||
000D 2808 00040 goto loop1
|
||||
000E 0FA3 00041 incfsz 23h
|
||||
000F 2808 00042 goto loop1
|
||||
00043
|
||||
00044 ;******************************************************************
|
||||
00045 ;in 20h steht ca. 5fH
|
||||
00046 ;in 21H ca. 17H
|
||||
00047 ;Z<>hlerstand 16-Bit ca. 175FH = 5983d
|
||||
00048
|
||||
00049 ende
|
||||
0010 2810 00050 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00051
|
||||
00052
|
||||
81
testfiles/TPicSim12.LST
Executable file
81
testfiles/TPicSim12.LST
Executable file
@@ -0,0 +1,81 @@
|
||||
00001 ;TPicSim12
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Funktion: Beschreiben und Lesen des EEPROMs
|
||||
00004 ;(c) St. Lehmann Ersterstellung: 11.05.2011
|
||||
00005 ;Definition einiger Symbole
|
||||
00006 ;19.05.2020 Korrektur WR-Bit (muss nach Ablauf der State Machine stehen)
|
||||
00007 ;18.10.2018 mod. f<>r HSO
|
||||
00008
|
||||
00009 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00010
|
||||
00011 indirect equ 0
|
||||
00012 status equ 03h
|
||||
00013 fsr equ 04h
|
||||
00014 ra equ 05h
|
||||
00015 rb equ 06h
|
||||
00016 count equ 0ch
|
||||
00017 eedata equ 08h
|
||||
00018 eeaddr equ 09h
|
||||
00019 eecon1 equ 08h ;auf Bank 1
|
||||
00020 eecon2 equ 09h ;auf Bank 1
|
||||
00021
|
||||
00022 ;Definition des Prozessors
|
||||
00023 device 16F84
|
||||
00024
|
||||
00025 ;Festlegen des Codebeginns
|
||||
00026 org 0
|
||||
00027 start
|
||||
0000 3000 00028 movlw 0 ;der EEPROM-Speicher von 0 bis 3FH (63) gef<65>llt
|
||||
0001 008C 00029 movwf count
|
||||
00030 schreiben
|
||||
0002 080C 00031 movf count,w
|
||||
0003 0089 00032 movwf eeaddr ;diese Adresse soll beschrieben werden
|
||||
0004 3AFF 00033 xorlw 255 ;Adresse invertieren
|
||||
0005 0088 00034 movwf eedata ;dieser Wert an obige Adresse schreiben
|
||||
00035
|
||||
0006 1683 00036 bsf status,5 ;auf Bank 1
|
||||
0007 1208 00037 bcf eecon1,4 ;EEIF zur<75>cksetzen, wird <20>berwacht
|
||||
0008 1508 00038 bsf eecon1,2 ;WREN-Bit setzen, sonst kein schreiben m<>glich
|
||||
00039
|
||||
0009 3055 00040 movlw 55h ;State-Machine anwerfen
|
||||
000A 0089 00041 movwf eecon2
|
||||
000B 30AA 00042 movlw 0AAh
|
||||
000C 0089 00043 movwf eecon2 ;wenn State-Maschine ok und WR-Bit gesetzt wird,
|
||||
00044 ;dann beginnt der Schreibvorgang
|
||||
000D 1488 00045 bsf eecon1,1 ;jetzt WR-Bit setzen, Schreibvorgang startet jetzt!
|
||||
00046
|
||||
00047 warte
|
||||
000E 1E08 00048 btfss eecon1,4 ;warte bis EEIF auf 1 ist
|
||||
000F 280E 00049 goto warte
|
||||
00050
|
||||
0010 1108 00051 bcf eecon1,2 ;WREN auf 0
|
||||
00052
|
||||
0011 1283 00053 bcf status,5 ;zur<75>ck auf Bank 0
|
||||
00054
|
||||
0012 0A8C 00055 incf count
|
||||
0013 080C 00056 movf count,w ;ist der Wert 40H erreicht
|
||||
0014 3C40 00057 sublw 40h
|
||||
0015 1D03 00058 btfss status,2 ;wenn 0, dann fertig
|
||||
0016 2802 00059 goto schreiben
|
||||
00060
|
||||
00061
|
||||
0017 018C 00062 clrf count ;jetzt gesamten Speicher lesen
|
||||
00063 lesen:
|
||||
0018 080C 00064 movf count,w
|
||||
0019 0089 00065 movwf eeaddr
|
||||
00066
|
||||
001A 1683 00067 bsf status,5 ;auf Bank 1
|
||||
001B 1408 00068 bsf eecon1,0 ;RD-Bit auf 1, wird vom PIC wieder auf 0 gesetzt
|
||||
001C 1283 00069 bcf status,5 ;zur<75>ck auf Bank 0
|
||||
00070
|
||||
001D 0808 00071 movf eedata,w ;Wert ins W-Register
|
||||
00072
|
||||
001E 0A8C 00073 incf count
|
||||
001F 080C 00074 movf count,w ;ist der Wert 40H erreicht
|
||||
0020 3C40 00075 sublw 40h
|
||||
0021 1D03 00076 btfss status,2 ;wenn 0, dann fertig
|
||||
0022 2818 00077 goto lesen
|
||||
00078
|
||||
00079 ende
|
||||
0023 2823 00080 goto ende
|
||||
00081
|
||||
45
testfiles/TPicSim13.LST
Executable file
45
testfiles/TPicSim13.LST
Executable file
@@ -0,0 +1,45 @@
|
||||
00001 ;TPicSim13
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Funktion: Lauflicht. Die Richtung wird durch RA,0 bestimmt
|
||||
00004 ;(c) St. Lehmann Ersterstellung: 11.05.2011
|
||||
00005 ;Definition einiger Symbole
|
||||
00006 ;18.10.2018 mod. f<>r HSO
|
||||
00007
|
||||
00008 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00009
|
||||
00010 indirect equ 0
|
||||
00011 status equ 03h
|
||||
00012 fsr equ 04h
|
||||
00013 ra equ 05h
|
||||
00014 rb equ 06h
|
||||
00015 rp0 equ 5
|
||||
00016
|
||||
00017 ;Definition des Prozessors
|
||||
00018 device 16F84
|
||||
00019
|
||||
00020 ;Festlegen des Codebeginns
|
||||
00021 org 0
|
||||
00022 start
|
||||
0000 1683 00023 bsf status,rp0 ;auf Bank 1 umschalten
|
||||
0001 0186 00024 clrf rb ;TRIS RB auf 0 = Ausgang setzen
|
||||
0002 1283 00025 bcf status,rp0 ;zur<75>ck auf Bank 0
|
||||
0003 0186 00026 clrf rb ;Ausg<73>bge auf 0
|
||||
0004 1403 00027 bsf status,0 ;Carry auf 1 setzen
|
||||
00028 loop
|
||||
0005 1C05 00029 btfss ra,0 ;in welche Richtung?
|
||||
0006 280B 00030 goto links
|
||||
00031 rechts
|
||||
0007 0C86 00032 rrf rb
|
||||
0008 1803 00033 btfsc status,0 ;ist Carry 1?
|
||||
0009 0C86 00034 rrf rb ;ja, dann nochmal schieben
|
||||
000A 2805 00035 goto loop
|
||||
00036
|
||||
00037 links
|
||||
000B 0D86 00038 rlf rb
|
||||
000C 1803 00039 btfsc status,0 ;ist Carry = 1
|
||||
000D 0D86 00040 rlf rb ;ja, nochmal schieben
|
||||
000E 2805 00041 goto loop
|
||||
00042
|
||||
00043 ende
|
||||
000F 280F 00044 goto ende
|
||||
00045
|
||||
45
testfiles/TPicSim14.LST
Executable file
45
testfiles/TPicSim14.LST
Executable file
@@ -0,0 +1,45 @@
|
||||
00001 ;TPicSim14
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Funktion: Leuchtband. Die Richtung wird durch RA,0 bestimmt
|
||||
00004 ;(c) St. Lehmann Ersterstellung: 11.05.2011
|
||||
00005 ;Definition einiger Symbole
|
||||
00006 ;18.10.2018 mod. f<>r HSO
|
||||
00007
|
||||
00008 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00009
|
||||
00010 indirect equ 0
|
||||
00011 status equ 03h
|
||||
00012 fsr equ 04h
|
||||
00013 ra equ 05h
|
||||
00014 rb equ 06h
|
||||
00015 rp0 equ 5
|
||||
00016
|
||||
00017 ;Definition des Prozessors
|
||||
00018 device 16F84
|
||||
00019
|
||||
00020 ;Festlegen des Codebeginns
|
||||
00021 org 0
|
||||
00022 start
|
||||
0000 1683 00023 bsf status,rp0 ;auf Bank 1 umschalten
|
||||
0001 0186 00024 clrf rb ;TRIS RB auf 0 = Ausgang setzen
|
||||
0002 1283 00025 bcf status,rp0 ;zur<75>ck auf Bank 0
|
||||
0003 0186 00026 clrf rb
|
||||
00027 loop
|
||||
0004 1403 00028 bsf status,0 ;Carry auf 1 setzen
|
||||
0005 1C05 00029 btfss ra,0 ;in welche Richtung?
|
||||
0006 280B 00030 goto links
|
||||
00031 rechts
|
||||
0007 0C86 00032 rrf rb
|
||||
0008 1803 00033 btfsc status,0 ;ist Carry 1?
|
||||
0009 0186 00034 clrf rb ;ja, neu starten
|
||||
000A 2804 00035 goto loop
|
||||
00036
|
||||
00037 links
|
||||
000B 0D86 00038 rlf rb
|
||||
000C 1803 00039 btfsc status,0 ;ist Carry = 1
|
||||
000D 0186 00040 clrf rb ;ja, neu starten
|
||||
000E 2804 00041 goto loop
|
||||
00042
|
||||
00043 ende
|
||||
000F 280F 00044 goto ende
|
||||
00045
|
||||
91
testfiles/TPicSim15.LST
Executable file
91
testfiles/TPicSim15.LST
Executable file
@@ -0,0 +1,91 @@
|
||||
00001 ;TPicSim15
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es wird die richtige Funktionsweise des Portlatch getestet
|
||||
00004 ;
|
||||
00005 ;(c) St. Lehmann
|
||||
00006 ;14.05.2020
|
||||
00007
|
||||
00008 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00009
|
||||
00010 ;Definition einiger Symbole
|
||||
00011 indirect equ 0
|
||||
00012 pcl equ 02h
|
||||
00013 status equ 03h
|
||||
00014 fsr equ 04h
|
||||
00015 ra equ 05h
|
||||
00016 rb equ 06h
|
||||
00017 pclath equ 0ah
|
||||
00018 intcon equ 0bh
|
||||
00019 rp0 equ 5 ;Bankumschaltbit
|
||||
00020
|
||||
00021 ;Definition des Prozessors
|
||||
00022 device 16F84
|
||||
00023 ;Festlegen des Codebeginns
|
||||
00024 org 0
|
||||
00025 start
|
||||
0000 2810 00026 goto main
|
||||
00027
|
||||
00028 init
|
||||
0001 1683 00029 bsf status,rp0 ;auf Bank 1 umschalten
|
||||
0002 300E 00030 movlw 0Eh ;Port A wird auf xxxo iiio eingestellt
|
||||
0003 0085 00031 movwf ra ;Trisregister Port A beschreiben
|
||||
0004 300F 00032 movlw 0Fh ;Port B wird auf oooo iiii eingestellt
|
||||
0005 0086 00033 movwf rb ;Trisregister Port B beschreiben
|
||||
0006 1283 00034 bcf status,rp0 ;zur<75>ck auf Bank0
|
||||
0007 0008 00035 return
|
||||
00036
|
||||
00037 trisRA
|
||||
0008 1683 00038 bsf status,rp0
|
||||
0009 0085 00039 movwf ra
|
||||
000A 1283 00040 bcf status,rp0
|
||||
000B 0008 00041 return
|
||||
00042
|
||||
00043 trisRb
|
||||
000C 1683 00044 bsf status,rp0
|
||||
000D 0086 00045 movwf rb
|
||||
000E 1283 00046 bcf status,rp0
|
||||
000F 0008 00047 return
|
||||
00048
|
||||
00049 main
|
||||
0010 2001 00050 call init ;Ports initialisieren
|
||||
0011 1405 00051 bsf ra,0 ;eine 1 an RA0 ausgeben
|
||||
0012 0000 00052 nop
|
||||
0013 1005 00053 bcf ra,0 ;eine 0 an RA0 ausgeben
|
||||
0014 0000 00054 nop
|
||||
0015 1386 00055 bcf rb,7 ;eine 0 an RB7 ausgeben
|
||||
0016 0000 00056 nop
|
||||
0017 1786 00057 bsf rb,7 ;eine 1 an RB7 ausgeben
|
||||
0018 0000 00058 nop
|
||||
00059
|
||||
00060 ;Funktionspr<70>fung an RA0
|
||||
0019 300F 00061 movlw 0Fh ;RA0 auf Eingang stellen
|
||||
001A 2008 00062 call trisRA
|
||||
001B 0000 00063 nop
|
||||
001C 0000 00064 nop
|
||||
001D 0000 00065 nop
|
||||
001E 1405 00066 bsf ra,0 ;nur das interne Latch wird beschrieben
|
||||
001F 0000 00067 nop ;der Pegel an RA0 <20>ndert sich noch nicht.
|
||||
0020 0000 00068 nop
|
||||
0021 0000 00069 nop
|
||||
0022 300E 00070 movlw 0Eh ;jetzt wird RA0 wieder auf Ausgang gestellt
|
||||
0023 2008 00071 call trisRA ;und die 1 kommt sofort am Pin RA0 an.
|
||||
0024 0000 00072 nop
|
||||
0025 0000 00073 nop
|
||||
0026 0000 00074 nop
|
||||
00075
|
||||
00076 ;Funktionspr<70>fung an RB7
|
||||
0027 308F 00077 movlw 08Fh ;RB7 auf Eingang wechseln
|
||||
0028 200C 00078 call trisRB
|
||||
0029 0000 00079 nop
|
||||
002A 0000 00080 nop
|
||||
002B 1386 00081 bcf rb,7 ;RB7 intern auf 0 setzen, Pin bleibt unver<65>ndert
|
||||
002C 0000 00082 nop
|
||||
002D 0000 00083 nop
|
||||
002E 300F 00084 movlw 0Fh ;RB7 wieder auf Ausgang setzen, die 0 erscheint
|
||||
002F 200C 00085 call trisRB ;sofort am Pin RB7
|
||||
0030 0000 00086 nop
|
||||
0031 0000 00087 nop
|
||||
00088
|
||||
00089 ende
|
||||
0032 2832 00090 goto ende
|
||||
00091
|
||||
33
testfiles/TPicSim2.LST
Executable file
33
testfiles/TPicSim2.LST
Executable file
@@ -0,0 +1,33 @@
|
||||
00001 ;TPicSim2
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es werden CALL, GOTO, RETLW, RETURN gepr<70>ft (kein RETFIE)
|
||||
00004 ;(c) St. Lehmann
|
||||
00005 ;Ersterstellung: 23.03.2016
|
||||
00006 ;mod. 18.10.2018 f<>r HSO
|
||||
00007 ;
|
||||
00008 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00009
|
||||
00010 ;Definition des Prozessors
|
||||
00011 device 16F84
|
||||
00012
|
||||
00013 ;Festlegen des Codebeginns
|
||||
00014 org 0
|
||||
00015 loop
|
||||
0000 3011 00016 movlw 11h ;in W steht nun 11h, Statusreg. unver<65>ndert
|
||||
0001 2006 00017 call up1 ;beim Call wird R<>cksprungadresse auf Stack gelegt
|
||||
0002 0000 00018 nop ;W = 36h, C=0, DC=0, Z=0
|
||||
0003 2008 00019 call up2 ;in W steht der R<>ckgabewert
|
||||
0004 0000 00020 nop ;W = 77h, DC=0, C=0, Z=0;
|
||||
0005 2800 00021 goto loop
|
||||
00022
|
||||
00023 ;UP1 z<>hlt zu W den Wert 25h hinzu und kehrt mit RETURN zur<75>ck
|
||||
0006 3E25 00024 up1 addlw 25h ;W = 36h, DC=0, C=0, Z=0
|
||||
0007 0008 00025 return
|
||||
00026
|
||||
00027 ;UP2 kehrt mit der Konstanten 77h zur<75>ck
|
||||
0008 3477 00028 up2 retlw 77h
|
||||
00029
|
||||
00030 ende
|
||||
0009 2809 00031 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00032
|
||||
00033
|
||||
62
testfiles/TPicSim3.LST
Executable file
62
testfiles/TPicSim3.LST
Executable file
@@ -0,0 +1,62 @@
|
||||
00001 ;TPicSim3
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es werden die Byte-orientieren File-Register Befehle gepr<70>ft
|
||||
00004 ;aber kein DECFSZ, INCFSZ, RLF, RRF
|
||||
00005 ;(c) St. Lehmann
|
||||
00006 ;Ersterstellung: 23.03.2016
|
||||
00007 ;Korrekturen: 09.05.2017 (Fehler gefunden durch: Dominik Vogel)
|
||||
00008 ;19.05.2020
|
||||
00009 ;mod. 18.10.2018 f<>r HSO
|
||||
00010
|
||||
00011 ;Hinweis:
|
||||
00012 ;Bei diesen Befehlen entscheidet das d-Bit (Destination), ob das Ergebnis
|
||||
00013 ;dieser Operation ins W- oder File-Register geschrieben wird. Wird im
|
||||
00014 ;Assemblercode der Befehl mit ",W" geschrieben, bedeutet dies, dass das
|
||||
00015 ;d-Bit 0 ist und das Ergebnis ins W-Register kommt. Fehlt ",W" ist das
|
||||
00016 ;d-Bit 1 und das Ergebnis wird ins Fileregister geschrieben.
|
||||
00017 ;
|
||||
00018 ;Alle Befehle die eine Fileregister-Adresse haben, k<>nnen auch "indirekt"
|
||||
00019 ;adressieren. Dies ist im Testfile TPicSim6.LST beschrieben.
|
||||
00020 ;
|
||||
00021 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00022
|
||||
00023 ;Definition einiger Symbole
|
||||
00024 ;f<>r den Benutzer frei verwendbare Register
|
||||
00025 wert1 equ 0ch ;Variable Nr.1
|
||||
00026 wert2 equ 0dh ;Variable Nr.2
|
||||
00027 ergeb equ 0eh ;Variable Nr.3
|
||||
00028
|
||||
00029 ;Definition des Prozessors
|
||||
00030 device 16F84
|
||||
00031
|
||||
00032 ;Festlegen des Codebeginns
|
||||
00033 org 0
|
||||
00034 loop
|
||||
0000 3011 00035 movlw 11h ;in W steht nun 11h, DC=?, C=?, Z=?
|
||||
0001 008C 00036 movwf wert1 ;diesen Wert abspeichern, DC=?, C=?, Z=?
|
||||
0002 3014 00037 movlw 14h ;W = 14h, DC=?, C=?, Z=?
|
||||
0003 070C 00038 addwf wert1,w ;W = 25h, DC=0, C=0, Z=0
|
||||
0004 078C 00039 addwf wert1 ;W = 25h, wert1 = 36h, DC=0, C=0, Z=0
|
||||
0005 050C 00040 andwf wert1,w ;W = 24h, wert1 = 36h, DC=0, C=0, Z=0
|
||||
0006 008D 00041 movwf wert2 ;W=24h, wert1=36, wert2=24h
|
||||
0007 018C 00042 clrf wert1 ;W=24h, wert1=0, wert2=24h, DC=0, C=0, Z=1
|
||||
0008 090D 00043 comf wert2,w ;W=DBh, wert1=0, wert2=24h, DC=0, C=0, Z=0
|
||||
0009 030C 00044 decf wert1,w ;W=FFh, wert1=0, wert2=24h, DC=0, C=0, Z=0
|
||||
000A 0A8D 00045 incf wert2 ;W=FFh, wert1=0, wert2=25h, DC=0, C=0, Z=0
|
||||
000B 088C 00046 movf wert1 ;W=FFh, wert1=0, wert2=25h, DC=0, C=0, Z=1
|
||||
000C 048C 00047 iorwf wert1 ;W=FFh, wert1=FFh, wert2=25h, DC=0, C=0, Z=0
|
||||
000D 020D 00048 subwf wert2,w ;W=26h, wert1=FFh, wert2=25h, DC=0, C=0, Z=0
|
||||
000E 0E8D 00049 swapf wert2 ;W=26h, wert1=FFh, wert2=52h, DC=0, C=0, Z=0
|
||||
000F 068C 00050 xorwf wert1 ;W=26h, wert1=D9h, wert2=52h, DC=0, C=0, Z=0
|
||||
0010 0100 00051 clrw ;W=00h, wert1=D9h, wert2=52h, DC=0, C=0, Z=1
|
||||
00052
|
||||
0011 020C 00053 subwf wert1,w ;W=D9h, wert1=D9h, wert2=52h, DC=1, C=1, Z=0
|
||||
0012 020D 00054 subwf wert2,w ;W=79h, wert1=D9h, wert2=52h, DC=0, C=0, Z=0
|
||||
0013 028D 00055 subwf wert2 ;W=79h, wert1=D9h, wert2=D9h, DC=0, C=0, Z=0
|
||||
0014 028D 00056 subwf wert2 ;W=79h, wert1=D9h, wert2=60h, DC=1, C=1, Z=0
|
||||
00057
|
||||
00058
|
||||
00059 ende
|
||||
0015 2815 00060 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00061
|
||||
00062
|
||||
107
testfiles/TPicSim4.LST
Executable file
107
testfiles/TPicSim4.LST
Executable file
@@ -0,0 +1,107 @@
|
||||
00001 ;TPicSim4
|
||||
00002 ;Programm zum Test des 16F84-Simulators.
|
||||
00003 ;Es werden die Befehle DECFSZ, INCFSZ, RLF, RRF gepr<70>ft
|
||||
00004 ;(c) St. Lehmann
|
||||
00005 ;Ersterstellung: 23.03.2016
|
||||
00006 ;Korrektur und erg<72>nzt 09.05.2017 durch: Dominik Vogel
|
||||
00007 ;mod. 18.10.2018 f<>r HSO
|
||||
00008 ;
|
||||
00009 list c=132 ;Zeilenl<6E>nge im LST auf 132 Zeichen setzen
|
||||
00010
|
||||
00011 ;Definition einiger Symbole
|
||||
00012 ;f<>r den Benutzer frei verwendbare Register
|
||||
00013 wert1 equ 0ch ;Variable Nr.1
|
||||
00014 wert2 equ 0dh ;Variable Nr.2
|
||||
00015 ergeb equ 0eh ;Variable Nr.3
|
||||
00016
|
||||
00017 ;Definition des Prozessors
|
||||
00018 device 16F84
|
||||
00019
|
||||
00020 ;Festlegen des Codebeginns
|
||||
00021 org 0
|
||||
00022 loop
|
||||
0000 3011 00023 movlw 11h ;in W steht nun 11h, DC=?, C=?, Z=?
|
||||
0001 008C 00024 movwf wert1 ;diesen Wert abspeichern, DC=?, C=?, Z=?
|
||||
0002 3E11 00025 addlw 11h ;l<>scht u.a. das Carry-Flag, DC=0, C=0, Z=0
|
||||
0003 0D8C 00026 rlf wert1 ;W=22h, wert1=22h, wert2=?? , DC=0, C=0, Z=0
|
||||
0004 0D8C 00027 rlf wert1 ;W=22h, wert1=44h, wert2=?? , DC=0, C=0, Z=0
|
||||
0005 0D8C 00028 rlf wert1 ;W=22h, wert1=88h, wert2=?? , DC=0, C=0, Z=0
|
||||
0006 0D0C 00029 rlf wert1,w ;W=10h, wert1=88h, wert2=?? , DC=0, C=1, Z=0
|
||||
0007 0D8C 00030 rlf wert1 ;W=10h, wert1=11h, wert2=?? , DC=0, C=1, Z=0
|
||||
0008 0D0C 00031 rlf wert1,w ;W=23h, wert1=11h, wert2=?? , DC=0, C=0, Z=0
|
||||
0009 0C8C 00032 rrf wert1 ;W=23h, wert1=08h, wert2=?? , DC=0, C=1, Z=0
|
||||
000A 008D 00033 movwf wert2 ;W=23h, wert1=08h, wert2=23h, DC=0, C=1, Z=0
|
||||
000B 0C8D 00034 rrf wert2 ;W=23h, wert1=08h, wert2=91h, DC=0, C=1, Z=0
|
||||
000C 0C0D 00035 rrf wert2,w ;W=C8h, wert1=08h, wert2=91h, DC=0, C=1, Z=0
|
||||
00036
|
||||
000D 3009 00037 movlw 9 ;W=09h, wert1=08h, wert2=91h, DC=0, C=1, Z=0
|
||||
000E 008C 00038 movwf wert1 ;W=09h, wert1=09h, wert2=91h, DC=0, C=1, Z=0
|
||||
000F 0100 00039 clrw ;W=00h, wert1=09h, wert2=91h, DC=0, C=1, Z=1
|
||||
00040 loop1
|
||||
0010 3E01 00041 addlw 1 ;W=01h, DC=0, C=0, Z=0
|
||||
00042 ;W=02h, DC=0, C=0, Z=0
|
||||
00043 ;W=03h, DC=0, C=0, Z=0
|
||||
00044 ;W=04h, DC=0, C=0, Z=0
|
||||
00045 ;W=05h, DC=0, C=0, Z=0
|
||||
00046 ;W=06h, DC=0, C=0, Z=0
|
||||
00047 ;W=07h, DC=0, C=0, Z=0
|
||||
00048 ;W=08h, DC=0, C=0, Z=0
|
||||
00049 ;W=09h, DC=0, C=0, Z=0
|
||||
0011 078D 00050 addwf wert2 ;wert2=92h, DC=0, C=0, Z=0
|
||||
00051 ;wert2=94h, DC=0, C=0, Z=0
|
||||
00052 ;wert2=97h, DC=0, C=0, Z=0
|
||||
00053 ;wert2=9Bh, DC=0, C=0, Z=0
|
||||
00054 ;wert2=A0h, DC=1, C=0, Z=0
|
||||
00055 ;wert2=A6h, DC=0, C=0, Z=0
|
||||
00056 ;wert2=ADh, DC=0, C=0, Z=0
|
||||
00057 ;wert2=B5h, DC=1, C=0, Z=0
|
||||
00058 ;wert2=BEh, DC=0, C=0, Z=0
|
||||
0012 0B8C 00059 decfsz wert1 ;wert1=08h, wert1=07h, ... DC,C und Z bleiben unver<65>ndert
|
||||
0013 2810 00060 goto loop1
|
||||
00061
|
||||
0014 30F0 00062 movlw 0f0h ;Wert wird bis 00h (<28>ber FFh) hochgez<65>hlt
|
||||
0015 008C 00063 movwf wert1
|
||||
0016 018D 00064 clrf wert2
|
||||
0017 0100 00065 clrw
|
||||
00066 loop2
|
||||
0018 070C 00067 addwf wert1,w ;W=F0h, wert1=F0h, wert2=00h, DC=0, C=0, Z=0
|
||||
00068 ;W=E1h, wert1=F1h, wert2=01h, DC=0, C=1, Z=0
|
||||
00069 ;W=D3h, wert1=F2h, wert2=02h, DC=0, C=1, Z=0
|
||||
00070 ;W=C6h, wert1=F3h, wert2=03h, DC=0, C=1, Z=0
|
||||
00071 ;W=BAh, wert1=F4h, wert2=04h, DC=0, C=1, Z=0
|
||||
00072 ;W=AFh, wert1=F5h, wert2=05h, DC=0, C=1, Z=0
|
||||
00073 ;W=A5h, wert1=F6h, wert2=06h, DC=1, C=1, Z=0
|
||||
00074 ;W=9Ch, wert1=F7h, wert2=07h, DC=0, C=1, Z=0
|
||||
00075 ;W=94h, wert1=F8h, wert2=08h, DC=1, C=1, Z=0
|
||||
00076 ;W=8Dh, wert1=F9h, wert2=09h, DC=0, C=1, Z=0
|
||||
00077 ;W=87h, wert1=FAh, wert2=0Ah, DC=1, C=1, Z=0
|
||||
00078 ;W=82h, wert1=FBh, wert2=0Bh, DC=1, C=1, Z=0
|
||||
00079 ;W=7Eh, wert1=FCh, wert2=0Ch, DC=0, C=1, Z=0
|
||||
00080 ;W=7Bh, wert1=FDh, wert2=0Dh, DC=1, C=1, Z=0
|
||||
00081 ;W=79h, wert1=FEh, wert2=0Eh, DC=1, C=1, Z=0
|
||||
00082 ;W=78h, wert1=FFh, wert2=0Fh, DC=1, C=1, Z=0
|
||||
00083
|
||||
0019 0A8D 00084 incf wert2 ;W=F0h, wert1=F0h, wert2=01h, DC=0, C=0, Z=0
|
||||
00085 ;W=E1h, wert1=F1h, wert2=02h, DC=0, C=1, Z=0
|
||||
00086
|
||||
00087 ;W=D3h, wert1=F2h, wert2=03h, DC=0, C=1, Z=0
|
||||
00088 ;W=C6h, wert1=F3h, wert2=04h, DC=0, C=1, Z=0
|
||||
00089 ;W=BAh, wert1=F4h, wert2=05h, DC=0, C=1, Z=0
|
||||
00090 ;W=AFh, wert1=F5h, wert2=06h, DC=0, C=1, Z=0
|
||||
00091 ;W=A5h, wert1=F6h, wert2=07h, DC=1, C=1, Z=0
|
||||
00092 ;W=9Ch, wert1=F7h, wert2=08h, DC=0, C=1, Z=0
|
||||
00093 ;W=94h, wert1=F8h, wert2=09h, DC=1, C=1, Z=0
|
||||
00094 ;W=8Dh, wert1=F9h, wert2=0Ah, DC=0, C=1, Z=0
|
||||
00095 ;W=87h, wert1=FAh, wert2=0Bh, DC=1, C=1, Z=0
|
||||
00096 ;W=82h, wert1=FBh, wert2=0Ch, DC=1, C=1, Z=0
|
||||
00097 ;W=7Eh, wert1=FCh, wert2=0Dh, DC=0, C=1, Z=0
|
||||
00098 ;W=7Bh, wert1=FDh, wert2=0Eh, DC=1, C=1, Z=0
|
||||
00099 ;W=79h, wert1=FEh, wert2=0Fh, DC=1, C=1, Z=0
|
||||
00100 ;W=78h, wert1=FFh, wert2=10h, DC=1, C=1, Z=0
|
||||
001A 0F8C 00101 incfsz wert1 ;wert1=F1h, F2h, F3h .. FFh, 00h, wert2 und Flags bleiben unver<65>ndert
|
||||
001B 2818 00102 goto loop2
|
||||
00103
|
||||
00104 ende
|
||||
001C 281C 00105 goto ende ;Endlosschleife, verhindert Nirwana
|
||||
00106
|
||||
00107
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user