Command-Erkennung
This commit is contained in:
151
src/main/java/fabrik/simulator/pic16f84/Commands.java
Normal file
151
src/main/java/fabrik/simulator/pic16f84/Commands.java
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
public class Commands {
|
||||||
|
public static void execute(){
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void decode(int instruction){
|
||||||
|
int jumpaddr = 0x7FF;
|
||||||
|
int fileregaddr = 0x7F;
|
||||||
|
int constant = 0xFF;
|
||||||
|
int bitaddr = 0x380;
|
||||||
|
int destinationbit = 0x80;
|
||||||
|
|
||||||
|
switch (instruction & 0x3800){
|
||||||
|
case 0b10000000000000:
|
||||||
|
System.out.println("CALL");
|
||||||
|
return;
|
||||||
|
case 0b10100000000000:
|
||||||
|
System.out.println("GOTO");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (instruction & 0x3F00){
|
||||||
|
case 0b00011100000000:
|
||||||
|
System.out.println("ADDWF");
|
||||||
|
return;
|
||||||
|
case 0b00010100000000:
|
||||||
|
System.out.println("ANDWF");
|
||||||
|
return;
|
||||||
|
case 0b00100100000000:
|
||||||
|
System.out.println("COMF");
|
||||||
|
return;
|
||||||
|
case 0b00001100000000:
|
||||||
|
System.out.println("DECF");
|
||||||
|
return;
|
||||||
|
case 0b00101100000000:
|
||||||
|
System.out.println("DECFSZ");
|
||||||
|
return;
|
||||||
|
case 0b00101000000000:
|
||||||
|
System.out.println("INCF");
|
||||||
|
return;
|
||||||
|
case 0b00111100000000:
|
||||||
|
System.out.println("INCFSZ");
|
||||||
|
return;
|
||||||
|
case 0b00010000000000:
|
||||||
|
System.out.println("IORWF");
|
||||||
|
return;
|
||||||
|
case 0b00100000000000:
|
||||||
|
System.out.println("MOVF");
|
||||||
|
return;
|
||||||
|
case 0b00110100000000:
|
||||||
|
System.out.println("RLF");
|
||||||
|
return;
|
||||||
|
case 0b00001000000000:
|
||||||
|
System.out.println("SUBWF");
|
||||||
|
return;
|
||||||
|
case 0b00111000000000:
|
||||||
|
System.out.println("SWAPF");
|
||||||
|
return;
|
||||||
|
case 0b00011000000000:
|
||||||
|
System.out.println("XORWF");
|
||||||
|
return;
|
||||||
|
case 0b11100100000000:
|
||||||
|
System.out.println("ANDLW");
|
||||||
|
return;
|
||||||
|
case 0b11101000000000:
|
||||||
|
System.out.println("XORLW");
|
||||||
|
return;
|
||||||
|
case 0b11100000000000:
|
||||||
|
System.out.println("IORLW");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (instruction & 0x3F80){
|
||||||
|
case 0b00000110000000:
|
||||||
|
System.out.println("CLRF");
|
||||||
|
return;
|
||||||
|
case 0b00000100000000:
|
||||||
|
System.out.println("CLRW");
|
||||||
|
return;
|
||||||
|
case 0b00000010000000:
|
||||||
|
System.out.println("MOVWF");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (instruction & 0x3C00){
|
||||||
|
case 0b01000000000000:
|
||||||
|
System.out.println("BCF");
|
||||||
|
return;
|
||||||
|
case 0b01010000000000:
|
||||||
|
System.out.println("BSF");
|
||||||
|
return;
|
||||||
|
case 0b01100000000000:
|
||||||
|
System.out.println("BTFSC");
|
||||||
|
return;
|
||||||
|
case 0b01110000000000:
|
||||||
|
System.out.println("BTFSS");
|
||||||
|
return;
|
||||||
|
case 0b11000000000000:
|
||||||
|
System.out.println("MOVLW");
|
||||||
|
return;
|
||||||
|
case 0b11010000000000:
|
||||||
|
System.out.println("RETLW");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (instruction & 0x3E00){
|
||||||
|
case 0b11111000000000:
|
||||||
|
System.out.println("ADDLW");
|
||||||
|
return;
|
||||||
|
case 0b11110000000000:
|
||||||
|
System.out.println("SUBLW");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (instruction){
|
||||||
|
case 0b01100100:
|
||||||
|
System.out.println("CLRWDT");
|
||||||
|
return;
|
||||||
|
case 0b1001:
|
||||||
|
System.out.println("RETFIE");
|
||||||
|
return;
|
||||||
|
case 0b1000:
|
||||||
|
System.out.println("RETURN");
|
||||||
|
return;
|
||||||
|
case 0b01100011:
|
||||||
|
System.out.println("SLEEP");
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (instruction == 0 || instruction == 0b0110000 || instruction == 0b01000000 || instruction == 0b00100000){
|
||||||
|
System.out.println("NOP");
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
System.out.println("Nicht gefunden!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -12,6 +12,8 @@ import java.io.IOException;
|
|||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
public class Controller_FileSelect {
|
public class Controller_FileSelect {
|
||||||
|
private int [] prog;
|
||||||
|
|
||||||
@FXML
|
@FXML
|
||||||
protected void selectFileLST(ActionEvent event) throws IOException {
|
protected void selectFileLST(ActionEvent event) throws IOException {
|
||||||
FileChooser fileChooser = new FileChooser();
|
FileChooser fileChooser = new FileChooser();
|
||||||
@ -22,15 +24,25 @@ public class Controller_FileSelect {
|
|||||||
File selectedFile = fileChooser.showOpenDialog(new Stage());
|
File selectedFile = fileChooser.showOpenDialog(new Stage());
|
||||||
|
|
||||||
if (selectedFile != null) {
|
if (selectedFile != null) {
|
||||||
int [] prog = ParseFile.parseTestDatei(selectedFile.getAbsolutePath());
|
prog = ParseFile.parseDatei(selectedFile.getAbsolutePath());
|
||||||
System.out.println(Arrays.toString(prog));
|
|
||||||
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow();
|
||||||
FXMLLoader fxmlLoader = new FXMLLoader(CreateWindow.class.getResource("MainBody.fxml"));
|
FXMLLoader fxmlLoader = new FXMLLoader(CreateWindow.class.getResource("MainBody.fxml"));
|
||||||
Scene scene = new Scene(fxmlLoader.load(), 1200, 800);
|
Scene scene = new Scene(fxmlLoader.load(), 1200, 800);
|
||||||
stage.setTitle("PIC16F84-Simulator - Hauptseite");
|
stage.setTitle("PIC16F84-Simulator - Hauptseite");
|
||||||
stage.setScene(scene);
|
stage.setScene(scene);
|
||||||
stage.show();
|
stage.show();
|
||||||
|
System.out.println("\n");
|
||||||
|
for (int i : prog){
|
||||||
|
if (i!=0) {
|
||||||
|
Commands.decode(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int[] getProg() {
|
||||||
|
return prog;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,4 +1,5 @@
|
|||||||
package fabrik.simulator.pic16f84;
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
public class Controller_MainBody {
|
public class Controller_MainBody {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
36
src/main/java/fabrik/simulator/pic16f84/DataRegister.java
Normal file
36
src/main/java/fabrik/simulator/pic16f84/DataRegister.java
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
package fabrik.simulator.pic16f84;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class DataRegister {
|
||||||
|
|
||||||
|
|
||||||
|
private static int [] dataRegister = new int[0xFF];
|
||||||
|
|
||||||
|
|
||||||
|
public static void initDataRegister() {
|
||||||
|
dataRegister[0x2] = 0b0;
|
||||||
|
dataRegister[0x3] = 0b00011000;
|
||||||
|
dataRegister[0xA] = 0b0;
|
||||||
|
dataRegister[0xB] = 0b0;
|
||||||
|
|
||||||
|
dataRegister[0x81] = 0b11111111;
|
||||||
|
dataRegister[0x82] = 0b0;
|
||||||
|
dataRegister[0x83] = 0b00011000;
|
||||||
|
dataRegister[0x85] = 0b11111000;
|
||||||
|
dataRegister[0x86] = 0b11111111;
|
||||||
|
dataRegister[0x88] = 0b0;
|
||||||
|
dataRegister[0x8A] = 0b0;
|
||||||
|
dataRegister[0x8B] = 0b0;
|
||||||
|
System.out.println(Arrays.toString(dataRegister));
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] getDataRegister() {
|
||||||
|
return dataRegister;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int getBit(int address, int bit) {
|
||||||
|
return (dataRegister[address] >> bit) & 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -7,7 +7,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ParseFile {
|
public class ParseFile {
|
||||||
public static int[] parseTestDatei(String dateiPfad) {
|
public static int[] parseDatei(String dateiPfad) {
|
||||||
List<String> zeilen = new ArrayList<>();
|
List<String> zeilen = new ArrayList<>();
|
||||||
|
|
||||||
// Bei diesem Schritt wird jetzt Zeile für Zeile das richtige Programm eingelesen
|
// Bei diesem Schritt wird jetzt Zeile für Zeile das richtige Programm eingelesen
|
||||||
|
|||||||
Reference in New Issue
Block a user