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!");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user