diff --git a/bin/Control/MyControlModel.class b/bin/Control/MyControlModel.class index 174dd84..8ab41f7 100644 Binary files a/bin/Control/MyControlModel.class and b/bin/Control/MyControlModel.class differ diff --git a/bin/Control/MyControlView.class b/bin/Control/MyControlView.class index f978d42..2907a22 100644 Binary files a/bin/Control/MyControlView.class and b/bin/Control/MyControlView.class differ diff --git a/bin/Model/BackendCommandProcessing/InformationConnecter.class b/bin/Model/BackendCommandProcessing/InformationConnecter.class index 933725e..82cd500 100644 Binary files a/bin/Model/BackendCommandProcessing/InformationConnecter.class and b/bin/Model/BackendCommandProcessing/InformationConnecter.class differ diff --git a/bin/Model/EepromLoader/ReadEepromFile.class b/bin/Model/EepromLoader/ReadEepromFile.class index 2258db2..8444bf8 100644 Binary files a/bin/Model/EepromLoader/ReadEepromFile.class and b/bin/Model/EepromLoader/ReadEepromFile.class differ diff --git a/bin/Model/InterruptHandling/InterruptServiceHandler.class b/bin/Model/InterruptHandling/InterruptServiceHandler.class index f8cb438..644bdc8 100644 Binary files a/bin/Model/InterruptHandling/InterruptServiceHandler.class and b/bin/Model/InterruptHandling/InterruptServiceHandler.class differ diff --git a/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class b/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class index 6305998..39a61e0 100644 Binary files a/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class and b/bin/Model/InterruptHandling/InterruptServiceHandlingTable.class differ diff --git a/bin/Model/Microcontroller/Bitmask.class b/bin/Model/Microcontroller/Bitmask.class index 2912924..505541b 100644 Binary files a/bin/Model/Microcontroller/Bitmask.class and b/bin/Model/Microcontroller/Bitmask.class differ diff --git a/bin/Model/Microcontroller/EEPROM.class b/bin/Model/Microcontroller/EEPROM.class index 1a83fd9..9ea4632 100644 Binary files a/bin/Model/Microcontroller/EEPROM.class and b/bin/Model/Microcontroller/EEPROM.class differ diff --git a/bin/Model/Microcontroller/PIC.class b/bin/Model/Microcontroller/PIC.class index 88b1956..9563a32 100644 Binary files a/bin/Model/Microcontroller/PIC.class and b/bin/Model/Microcontroller/PIC.class differ diff --git a/bin/Model/Microcontroller/RAM.class b/bin/Model/Microcontroller/RAM.class index cfd5351..754ea89 100644 Binary files a/bin/Model/Microcontroller/RAM.class and b/bin/Model/Microcontroller/RAM.class differ diff --git a/bin/Model/Microcontroller/RUNTIMER.class b/bin/Model/Microcontroller/RUNTIMER.class index e66e5f3..89956d8 100644 Binary files a/bin/Model/Microcontroller/RUNTIMER.class and b/bin/Model/Microcontroller/RUNTIMER.class differ diff --git a/bin/Model/Microcontroller/STACK.class b/bin/Model/Microcontroller/STACK.class index e56d123..95d928c 100644 Binary files a/bin/Model/Microcontroller/STACK.class and b/bin/Model/Microcontroller/STACK.class differ diff --git a/bin/Model/MyModel.class b/bin/Model/MyModel.class index 73e63a6..0f21172 100644 Binary files a/bin/Model/MyModel.class and b/bin/Model/MyModel.class differ diff --git a/bin/Model/MyModelData.class b/bin/Model/MyModelData.class index d8df1cf..9fa05f6 100644 Binary files a/bin/Model/MyModelData.class and b/bin/Model/MyModelData.class differ diff --git a/bin/Model/ProgramStepInformation.class b/bin/Model/ProgramStepInformation.class index fe123a3..b86b760 100644 Binary files a/bin/Model/ProgramStepInformation.class and b/bin/Model/ProgramStepInformation.class differ diff --git a/bin/Runtime/Main.class b/bin/Runtime/Main.class index 062d5f7..428fc79 100644 Binary files a/bin/Runtime/Main.class and b/bin/Runtime/Main.class differ diff --git a/bin/Runtime/TODO.class b/bin/Runtime/TODO.class index ee39889..274e38d 100644 Binary files a/bin/Runtime/TODO.class and b/bin/Runtime/TODO.class differ diff --git a/bin/View/GUIAbout.class b/bin/View/GUIAbout.class index 66cc5d9..f6644e6 100644 Binary files a/bin/View/GUIAbout.class and b/bin/View/GUIAbout.class differ diff --git a/bin/View/GUIHelp.class b/bin/View/GUIHelp.class index fbdad1d..04e0af4 100644 Binary files a/bin/View/GUIHelp.class and b/bin/View/GUIHelp.class differ diff --git a/bin/View/GUIMCMenu.class b/bin/View/GUIMCMenu.class index b26420f..ff5f92e 100644 Binary files a/bin/View/GUIMCMenu.class and b/bin/View/GUIMCMenu.class differ diff --git a/bin/View/GUIMainFrame.class b/bin/View/GUIMainFrame.class index 8f9bce6..26852d0 100644 Binary files a/bin/View/GUIMainFrame.class and b/bin/View/GUIMainFrame.class differ diff --git a/bin/View/GUIMenuBar.class b/bin/View/GUIMenuBar.class index 085dbe6..febde23 100644 Binary files a/bin/View/GUIMenuBar.class and b/bin/View/GUIMenuBar.class differ diff --git a/bin/View/GUIPorts.class b/bin/View/GUIPorts.class index 2eff123..fed0fb1 100644 Binary files a/bin/View/GUIPorts.class and b/bin/View/GUIPorts.class differ diff --git a/bin/View/GUIProgramMemory.class b/bin/View/GUIProgramMemory.class index 828af85..4542f06 100644 Binary files a/bin/View/GUIProgramMemory.class and b/bin/View/GUIProgramMemory.class differ diff --git a/bin/View/GUIRamTable.class b/bin/View/GUIRamTable.class index 3a49311..351374d 100644 Binary files a/bin/View/GUIRamTable.class and b/bin/View/GUIRamTable.class differ diff --git a/bin/View/GUIRegister.class b/bin/View/GUIRegister.class index 74779b9..2a14ab7 100644 Binary files a/bin/View/GUIRegister.class and b/bin/View/GUIRegister.class differ diff --git a/bin/View/GUIRegistersDetailed.class b/bin/View/GUIRegistersDetailed.class index ac92842..2ef7739 100644 Binary files a/bin/View/GUIRegistersDetailed.class and b/bin/View/GUIRegistersDetailed.class differ diff --git a/bin/View/GUIStack.class b/bin/View/GUIStack.class index 987bcfc..430080e 100644 Binary files a/bin/View/GUIStack.class and b/bin/View/GUIStack.class differ diff --git a/bin/View/GUITestFileTable.class b/bin/View/GUITestFileTable.class index 034a802..1598f0d 100644 Binary files a/bin/View/GUITestFileTable.class and b/bin/View/GUITestFileTable.class differ diff --git a/bin/View/GUITime.class b/bin/View/GUITime.class index 94c61f3..6ec77d8 100644 Binary files a/bin/View/GUITime.class and b/bin/View/GUITime.class differ diff --git a/bin/View/IMyView.class b/bin/View/IMyView.class index da06a6b..194ccb6 100644 Binary files a/bin/View/IMyView.class and b/bin/View/IMyView.class differ diff --git a/bin/View/MyColors.class b/bin/View/MyColors.class index b2ccf60..960b0d4 100644 Binary files a/bin/View/MyColors.class and b/bin/View/MyColors.class differ diff --git a/bin/View/MyView.class b/bin/View/MyView.class index 94b5bd5..e473f67 100644 Binary files a/bin/View/MyView.class and b/bin/View/MyView.class differ diff --git a/lib/hamcrest-core-1.3.jar b/lib/hamcrest-core-1.3.jar new file mode 100644 index 0000000..9d5fe16 Binary files /dev/null and b/lib/hamcrest-core-1.3.jar differ diff --git a/lib/junit-4.13.2.jar b/lib/junit-4.13.2.jar new file mode 100644 index 0000000..6da55d8 Binary files /dev/null and b/lib/junit-4.13.2.jar differ diff --git a/src/Control/MyControlModel.java b/src/Control/MyControlModel.java index 2e39df7..4b1ecbc 100644 --- a/src/Control/MyControlModel.java +++ b/src/Control/MyControlModel.java @@ -28,6 +28,7 @@ public class MyControlModel implements ActionListener { JCheckBox oWDTEnabled; JComboBox oQuarzIntervals; ArrayList oMenuItems; + ArrayList oPorts; ConcurrentLinkedQueue qCommandsForModel; ConcurrentLinkedQueue qDataForModel; @@ -48,6 +49,7 @@ public class MyControlModel implements ActionListener { oBreakpoints = oMyView.getGUITestFileTable().getCheckboxes(); oWDTEnabled = oMyView.getGUITime().getWDTEnableCheckbox(); oQuarzIntervals = oMyView.getGUITime().getQuarzComboBox(); + oPorts = oMyView.getGUIPorts().getPorts(); oMenuItems = oMyView.getGUIMenuBar().getMenuItems(); addActionListeners(); } @@ -200,6 +202,7 @@ public class MyControlModel implements ActionListener { qDataForModel.add(oMyModelData); } + //Menuitems int i = 0; for (JMenuItem oMenuItem : oMenuItems) { if (e.getSource() == oMenuItem) { @@ -277,8 +280,128 @@ public class MyControlModel implements ActionListener { } i++; } + + //Ports checked/unchecked? + i = 0; + for (JCheckBox oPort : oPorts) { + if (e.getSource() == oPort) { + switch (i) { + case 0: { + //RA0 + oPIC.getRam().set_RA0(oPort.isSelected()); + }break; + case 1: { + //RA1 + oPIC.getRam().set_RA1(oPort.isSelected()); + }break; + case 2: { + //RA2 + oPIC.getRam().set_RA2(oPort.isSelected()); + }break; + case 3: { + //RA3 + oPIC.getRam().set_RA3(oPort.isSelected()); + }break; + case 4: { + //RA4 + oPIC.getRam().set_RA4_T0CKI(oPort.isSelected()); + }break; + case 5: { + //TRISA0 + oPIC.getRam().set_TRISA0(oPort.isSelected()); + }break; + case 6: { + //TRISA1 + oPIC.getRam().set_TRISA1(oPort.isSelected()); + }break; + case 7: { + //TRISA2 + oPIC.getRam().set_TRISA2(oPort.isSelected()); + }break; + case 8: { + //TRISA3 + oPIC.getRam().set_TRISA3(oPort.isSelected()); + }break; + case 9: { + //TRISA4 + oPIC.getRam().set_TRISA4(oPort.isSelected()); + }break; + case 10: { + //RB0 + oPIC.getRam().set_RB0_INT(oPort.isSelected()); + }break; + case 11: { + //RB1 + oPIC.getRam().set_RB1(oPort.isSelected()); + }break; + case 12: { + //RB2 + oPIC.getRam().set_RB2(oPort.isSelected()); + }break; + case 13: { + //RB3 + oPIC.getRam().set_RB3(oPort.isSelected()); + }break; + case 14: { + //RB4 + oPIC.getRam().set_RB4(oPort.isSelected()); + }break; + case 15: { + //RB5 + oPIC.getRam().set_RB5(oPort.isSelected()); + }break; + case 16: { + //RB6 + oPIC.getRam().set_RB6(oPort.isSelected()); + }break; + case 17: { + //RB7 + oPIC.getRam().set_RB7(oPort.isSelected()); + }break; + case 18: { + //TRISB0 + oPIC.getRam().set_TRISB0(oPort.isSelected()); + }break; + case 19: { + //TRISB1 + oPIC.getRam().set_TRISB1(oPort.isSelected()); + }break; + case 20: { + //TRISB2 + oPIC.getRam().set_TRISB2(oPort.isSelected()); + }break; + case 21: { + //TRISB3 + oPIC.getRam().set_TRISB3(oPort.isSelected()); + }break; + case 22: { + //TRISB4 + oPIC.getRam().set_TRISB4(oPort.isSelected()); + }break; + case 23: { + //TRISB5 + oPIC.getRam().set_TRISB5(oPort.isSelected()); + }break; + case 24: { + //TRISB6 + oPIC.getRam().set_TRISB6(oPort.isSelected()); + }break; + case 25: { + //TRISB7 + oPIC.getRam().set_TRISB7(oPort.isSelected()); + }break; + } + //Send changes to model + oMyModelData.setPIC(oPIC); + qDataForModel.add(oMyModelData); + } + i++; + } } + /** + * Adds action listeners to all elements of view which are referrenced. + */ private void addActionListeners() { if (oBreakpoints != null) { for (JCheckBox oBreakpoint : oBreakpoints) { @@ -301,6 +424,10 @@ public class MyControlModel implements ActionListener { oMenuItem.addActionListener(this); } } - + if (oPorts != null) { + for (JCheckBox oCheckbox : oPorts) { + oCheckbox.addActionListener(this); + } + } } } \ No newline at end of file diff --git a/src/Model/InterruptHandling/InterruptServiceHandler.java b/src/Model/InterruptHandling/InterruptServiceHandler.java index 9d54156..bca602c 100644 --- a/src/Model/InterruptHandling/InterruptServiceHandler.java +++ b/src/Model/InterruptHandling/InterruptServiceHandler.java @@ -1,11 +1,13 @@ package Model.InterruptHandling; -public class InterruptServiceHandler extends Thread { +import Model.Microcontroller.PIC; - public InterruptServiceHandler() {} +public class InterruptServiceHandler { - public void run() { + private PIC oPIC; + public InterruptServiceHandler(PIC oPIC) { + this.oPIC = oPIC; } diff --git a/src/Model/Microcontroller/PIC.java b/src/Model/Microcontroller/PIC.java index 483f8a6..20ce398 100755 --- a/src/Model/Microcontroller/PIC.java +++ b/src/Model/Microcontroller/PIC.java @@ -155,20 +155,17 @@ public class PIC { * AND’ed with the eight bit literal 'k'. The * result is placed in the W register. */ - public void ANDLW(int eightK) - { + public void ANDLW(int eightK) { int wRegValue = get_WRegister(); int result = wRegValue & eightK; //If result is zero. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero. - else - { + else { Ram.set_Zeroflag(false); } @@ -177,8 +174,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -194,8 +192,7 @@ public class PIC { * stored in the W register. If ’d’ is 1 the result is * stored back in register ’f’. */ - public void ADDWF(int destinationBit, int registerFileAddress) - { + public void ADDWF(int destinationBit, int registerFileAddress) { //Get Value of int wRegValue = get_WRegister(); //Get Value of RAM-Bank-RP0Bit Address. @@ -205,33 +202,28 @@ public class PIC { int result = wRegValue + regFileAddrValue; //If result is zero. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero. - else - { + else { Ram.set_Zeroflag(false); } //If result is greater than 255. - if (result > 255) - { + if (result > 255) { result &= 255; Ram.set_Carryflag(true); } //If result is smaller than 0. - else if (result < 0) - { + else if (result < 0) { result &= 255; Ram.set_Carryflag(true); } - else - { + else { Ram.set_Carryflag(false); } @@ -239,33 +231,30 @@ public class PIC { int dcResult = (wRegValue & 15) + (regFileAddrValue & 15); //If the result is greater than 15, DC-Flag is set true. - if (dcResult > 15) - { + if (dcResult > 15) { Ram.set_Digitcarryflag(true); } //If the result is smaller or equal to 15, DC-Flag is set false. - else - { + else { Ram.set_Digitcarryflag(false); } //If the destinationbit is 0, the result is written into the - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If the destinationbit is 1, the result is written into the RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -281,8 +270,7 @@ public class PIC { * ter. If 'd' is 1 the result is stored back in * register 'f'. */ - public void ANDWF(int destinationBit, int registerFileAddress) - { + public void ANDWF(int destinationBit, int registerFileAddress) { //Get Value of int wRegValue = get_WRegister(); //Get Value of RAM-Bank-RP0Bit Address. @@ -292,33 +280,30 @@ public class PIC { int result = wRegValue & regFileAddrValue; //If result is zero. - if (result == 0) - { + if (result == 0) { Ram.set_Zeroflag(true); } //If result is not zero. - else - { + else { Ram.set_Zeroflag(false); } //If the destinationbit is 0, the result is written into the - if (destinationBit == 0) - { + if (destinationBit == 0) { setWRegister(result); } //If the destinationbit is 1, the result is written into the RAM. - else - { + else { Ram.set_Element_X_Of_Bank_Y_To_Z(registerFileAddress, Ram.get_RP0Bit(), result); } //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -331,8 +316,7 @@ public class PIC { * * Bit ’b’ in register ’f’ is cleared . */ - public void BCF(int bitaddress, int registerFileAddress) - { + public void BCF(int bitaddress, int registerFileAddress) { //Get bitmask to clear bit in fileaddress. int bitMask = bitMaskClearBitArray[bitaddress]; //Get Value of RAM-Bank-RP0Bit Address. @@ -347,8 +331,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -366,29 +351,28 @@ public class PIC { * executed instead, making this a 2TCY * instruction. */ - public void BTFSC(int bitaddress, int registerFileAddress) - { + public void BTFSC(int bitaddress, int registerFileAddress) { //Get bitmask to AND with fileaddress to get bit. int bitMask = bitMaskSetBitArray[bitaddress]; //Get Value of RAM-Bank-RP0Bit Address. int regFileAddrValue = Ram.get_Value_Of_Bank_RP0_Bit_Of_Element_At_Adress(Ram.get_RP0Bit(), registerFileAddress); //If bit at bitaddress is 1, next instruction is executed. - if ((bitMask & regFileAddrValue) == bitMask) - { + if ((bitMask & regFileAddrValue) == bitMask) { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } } //If bit at bitaddress is 0, next instruction will be replaced by a NOP. - else - { + else { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Execute NOP. NOP(); } @@ -418,8 +402,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -446,16 +431,18 @@ public class PIC { if ((bitMask & regFileAddrValue) != bitMask) { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } } //If bit at bitaddress is 1, next instruction will be replaced by a NOP. else { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Execute NOP. NOP(); } @@ -484,8 +471,9 @@ public class PIC { Ram.set_Programcounter(elevenK + ((Ram.get_PCLATH() & 0b11000) << 8)); //Increment TMR0 if internal instruction cycle assigned to TMR0. - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b11111111); @@ -506,8 +494,9 @@ public class PIC { Ram.set_Zeroflag(true); //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -528,8 +517,9 @@ public class PIC { Ram.set_Zeroflag(true); //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -555,8 +545,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -603,8 +594,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -644,16 +636,18 @@ public class PIC { if (regFileAddrValue != 0) { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } } //If the dekremented value equals zero, a NOP is executed and the other instruction will be dismissed. else { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } NOP(); } @@ -703,8 +697,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -727,8 +722,9 @@ public class PIC { Ram.set_Programcounter(elevenK + ((Ram.get_PCLATH() & 0b11000) << 8)); //Increment TMR0 if internal instruction cycle assigned to TMR0. - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -777,8 +773,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -831,8 +828,9 @@ public class PIC { else { ///Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Call NOP. NOP(); @@ -870,8 +868,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -913,8 +912,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -935,8 +935,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -975,8 +976,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -995,8 +997,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b11111111); @@ -1013,8 +1016,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b11111111); @@ -1042,8 +1046,9 @@ public class PIC { //Write returnAddress into programcounter. Ram.set_Programcounter(returnAddress); //Increment TMR0 if assigned to TMR0. - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1059,8 +1064,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1088,8 +1094,9 @@ public class PIC { //Write returnAddress into programcounter. Ram.set_Programcounter(returnAddress); //Increment TMR0 if assigned to TMR0. - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1112,8 +1119,9 @@ public class PIC { //Write returnAddress into programcounter. Ram.set_Programcounter(returnAddress); //Increment TMR0 if assigned to TMR0. - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1170,8 +1178,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1227,8 +1236,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1252,8 +1262,9 @@ public class PIC { //Not implemented //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1310,8 +1321,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1349,8 +1361,7 @@ public class PIC { int dcResult = (regFileAddrValue & 15) + (wRegValue & 15) + 1; //If the result is greater than 15, DC-Flag is set true. - if (dcResult > 15) - { + if (dcResult > 15) { Ram.set_Digitcarryflag(true); } @@ -1387,8 +1398,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1426,8 +1438,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1453,8 +1466,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1486,8 +1500,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); @@ -1531,8 +1546,9 @@ public class PIC { //Increment programcounter and TMR0 if assigned to TMR0. Ram.inkrement_Programcounter(1, 0); //Kind of call - if (Ram.get_T0CS() == false) + if (Ram.get_T0CS() == false) { Ram.increment_TMR0(); + } //Each Instruction has to split Programmcounter to PC and PCLATH because Ram can't see RAM. Ram.set_PCL(Ram.get_Programcounter() & 0b0000011111111); diff --git a/src/Model/Microcontroller/RAM.java b/src/Model/Microcontroller/RAM.java index 6fc13e4..9ec8024 100755 --- a/src/Model/Microcontroller/RAM.java +++ b/src/Model/Microcontroller/RAM.java @@ -241,41 +241,24 @@ public class RAM { } } - /** - * @returns value of TMR0. - */ public synchronized int get_TMR0() { return bank0[1]; } - /** - * Sets PCL to value. - * @param value PCL is set to. - */ public synchronized void set_PCL(int value) { bank0[2] = value; bank1[2] = value; } - /** - * @returns value of PCL - */ public synchronized int get_PCL() { return bank0[2]; } - /** - * Sets STATUS-register to value. - * @param value STATUS-register is set to. - */ public synchronized void set_STATUS(int value) { bank0[3] = value; bank1[3] = value; } - /** - * @returns STATUS-register. - */ public synchronized int get_STATUS() { return bank0[3]; } @@ -513,7 +496,6 @@ public class RAM { } else { status &= 0b11111110; } - set_STATUS(status); } @@ -528,7 +510,6 @@ public class RAM { } else { status &= 0b11111101; } - set_STATUS(status); } @@ -543,7 +524,6 @@ public class RAM { } else { status &= 0b11111011; } - set_STATUS(status); } @@ -558,7 +538,6 @@ public class RAM { } else { status &= 0b11110111; } - set_STATUS(status); } @@ -573,7 +552,6 @@ public class RAM { } else { status &= 0b11101111; } - set_STATUS(status); } @@ -588,7 +566,6 @@ public class RAM { } else { status &= 0b11011111; } - set_STATUS(status); } @@ -603,7 +580,6 @@ public class RAM { } else { status &= 0b10111111; } - set_STATUS(status); } @@ -618,7 +594,6 @@ public class RAM { } else { status &= 0b01111111; } - set_STATUS(status); } @@ -677,7 +652,6 @@ public class RAM { } else { portA &= 0b11111110; } - set_PORTA(portA); } @@ -700,7 +674,6 @@ public class RAM { } else { portA &= 0b11111101; } - set_PORTA(portA); } @@ -723,7 +696,6 @@ public class RAM { } else { portA &= 0b11111011; } - set_PORTA(portA); } @@ -746,292 +718,182 @@ public class RAM { } else { portA &= 0b11110111; } - set_PORTA(portA); } - public synchronized boolean get_RA3() - { - { - return (get_PORTA() & 0b00001000) == 8; - } + public synchronized boolean get_RA3() { + return (get_PORTA() & 0b00001000) == 8; } //External Clockimpulse for Timer0 - public synchronized void set_RA4_T0CKI(boolean value) - { + public synchronized void set_RA4_T0CKI(boolean value) { int portA = get_PORTA(); - if (value) - { + if (value) { portA |= 0b00010000; - } - - else - { + } else { portA &= 0b11101111; } - set_PORTA(portA); } - public synchronized boolean get_RA4_T0CKI() - { - { - return (get_PORTA() & 0b00010000) == 16; - } + public synchronized boolean get_RA4_T0CKI() { + return (get_PORTA() & 0b00010000) == 16; } //Bank0 PortB - public synchronized void set_RB0_INT(boolean value) - { + public synchronized void set_RB0_INT(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b00000001; - } - - else - { + } else { portB &= 0b11111110; } - set_PORTB(portB); } - public synchronized boolean get_RB0_INT() - { - { - return (get_PORTB() & 0b00000001) == 1; - } + public synchronized boolean get_RB0_INT() { + return (get_PORTB() & 0b00000001) == 1; } - public synchronized void set_RB1(boolean value) - { + public synchronized void set_RB1(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b00000010; - } - - else - { + } else { portB &= 0b11111101; } - set_PORTB(portB); } - public synchronized boolean get_RB1() - { - { - return (get_PORTB() & 0b00000010) == 2; - } + public synchronized boolean get_RB1() { + return (get_PORTB() & 0b00000010) == 2; } - public synchronized void set_RB2(boolean value) - { + public synchronized void set_RB2(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b00000100; - } - - else - { + } else { portB &= 0b11111011; } - set_PORTB(portB); } - public synchronized boolean get_RB2() - { + public synchronized boolean get_RB2() { return (get_PORTB() & 0b00000100) == 4; } - public synchronized void set_RB3(boolean value) - { + public synchronized void set_RB3(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b00001000; - } - - else - { + } else { portB &= 0b11110111; } - set_PORTB(portB); } - public synchronized boolean get_RB3() - { - { - return (get_PORTB() & 0b00001000) == 8; - } + public synchronized boolean get_RB3() { + return (get_PORTB() & 0b00001000) == 8; } - public synchronized void set_RB4(boolean value) - { + public synchronized void set_RB4(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b00010000; - } - - else - { + } else { portB &= 0b11101111; } - set_PORTB(portB); } - public synchronized boolean get_RB4() - { - { - return (get_PORTB() & 0b00010000) == 16; - } + public synchronized boolean get_RB4() { + return (get_PORTB() & 0b00010000) == 16; } - public synchronized void set_RB5(boolean value) - { + public synchronized void set_RB5(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b00100000; - } - - else - { + } else { portB &= 0b11011111; } - set_PORTB(portB); } - public synchronized boolean get_RB5() - { - { - return (get_PORTB() & 0b00100000) == 32; - } + public synchronized boolean get_RB5() { + return (get_PORTB() & 0b00100000) == 32; } - public synchronized void set_RB6(boolean value) - { + public synchronized void set_RB6(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b01000000; - } - - else - { + } else { portB &= 0b10111111; } - set_PORTB(portB); } - public synchronized boolean get_RB6() - { - { - return (get_PORTB() & 0b01000000) == 64; - } + public synchronized boolean get_RB6() { + return (get_PORTB() & 0b01000000) == 64; } - public synchronized void set_RB7(boolean value) - { + public synchronized void set_RB7(boolean value) { int portB = get_PORTB(); - if (value) - { + if (value) { portB |= 0b10000000; - } - - else - { + } else { portB &= 0b01111111; } - set_PORTB(portB); } - public synchronized boolean get_RB7() - { - { - return (get_PORTB() & 0b10000000) == 128; - } + public synchronized boolean get_RB7() { + return (get_PORTB() & 0b10000000) == 128; } //Bank0 INTCON - public synchronized void set_RBIF(boolean value) - { + public synchronized void set_RBIF(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b00000001; - } - - else - { + } else { intcon &= 0b11111110; } - set_INTCON(intcon); } - public synchronized boolean get_RBIF() - { - { - return (get_INTCON() & 0b00000001) == 1; - } + public synchronized boolean get_RBIF() { + return (get_INTCON() & 0b00000001) == 1; } - public synchronized void set_INTF(boolean value) - { + public synchronized void set_INTF(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b00000010; - } - - else - { + } else { intcon &= 0b11111101; } - set_INTCON(intcon); } - public synchronized boolean get_INTF() - { - { - return (get_INTCON() & 0b00000010) == 2; - } + public synchronized boolean get_INTF() { + return (get_INTCON() & 0b00000010) == 2; } - public synchronized void set_T0IF(boolean value) - { + public synchronized void set_T0IF(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b00000100; - } - - else - { + } else { intcon &= 0b11111011; } - set_INTCON(intcon); } - public synchronized boolean get_T0IF() - { - { - return (get_INTCON() & 0b00000100) == 4; - } + public synchronized boolean get_T0IF() { + return (get_INTCON() & 0b00000100) == 4; } public synchronized void set_RBIE(boolean value) { @@ -1041,177 +903,110 @@ public class RAM { } else { intcon &= 0b11110111; } - set_INTCON(intcon); } - public synchronized boolean get_RBIE() - { - { - return (get_INTCON() & 0b00001000) == 8; - } + public synchronized boolean get_RBIE() { + return (get_INTCON() & 0b00001000) == 8; } - public synchronized void set_INTE(boolean value) - { + public synchronized void set_INTE(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b00010000; - } - - else - { + } else { intcon &= 0b11101111; } - set_INTCON(intcon); } - public synchronized boolean get_INTE() - { - { - return (get_INTCON() & 0b00010000) == 16; - } + public synchronized boolean get_INTE() { + return (get_INTCON() & 0b00010000) == 16; } - public synchronized void set_T0IE(boolean value) - { + public synchronized void set_T0IE(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b00100000; - } - - else - { + } else { intcon &= 0b11011111; } - set_INTCON(intcon); } - public synchronized boolean get_T0IE() - { - { - return (get_INTCON() & 0b00100000) == 32; - } + public synchronized boolean get_T0IE() { + return (get_INTCON() & 0b00100000) == 32; } - public synchronized void set_EEIE(boolean value) - { + public synchronized void set_EEIE(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b01000000; - } - - else - { + } else { intcon &= 0b10111111; } - set_INTCON(intcon); } - public synchronized boolean get_EEIE() - { - { - return (get_INTCON() & 0b01000000) == 64; - } + public synchronized boolean get_EEIE() { + return (get_INTCON() & 0b01000000) == 64; } - public synchronized void set_GIE(boolean value) - { + public synchronized void set_GIE(boolean value) { int intcon = get_INTCON(); - if (value) - { + if (value) { intcon |= 0b10000000; - } - - else - { + } else { intcon &= 0b01111111; } - set_INTCON(intcon); } - public synchronized boolean get_GIE() - { - { - return (get_INTCON() & 0b10000000) == 128; - } + public synchronized boolean get_GIE() { + return (get_INTCON() & 0b10000000) == 128; } //Bank1 OPTION_REG - public synchronized void set_PS0(boolean value) - { + public synchronized void set_PS0(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b00000001; - } - - else - { + } else { option &= 0b11111110; } - set_OPTION(option); } - public synchronized boolean get_PS0() - { - { - return (get_OPTION() & 0b00000001) == 1; - } + public synchronized boolean get_PS0() { + return (get_OPTION() & 0b00000001) == 1; } - public synchronized void set_PS1(boolean value) - { + public synchronized void set_PS1(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b00000010; - } - - else - { + } else { option &= 0b11111101; } - set_OPTION(option); } - public synchronized boolean get_PS1() - { - { - return (get_OPTION() & 0b00000010) == 2; - } + public synchronized boolean get_PS1() { + return (get_OPTION() & 0b00000010) == 2; } - public synchronized void set_PS2(boolean value) - { + public synchronized void set_PS2(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b00000100; - } - - else - { + } else { option &= 0b11111011; } - set_OPTION(option); } - public synchronized boolean get_PS2() - { - { - return (get_OPTION() & 0b00000100) == 4; - } + public synchronized boolean get_PS2() { + return (get_OPTION() & 0b00000100) == 4; } public synchronized int get_TMR0_PrescalerRate() { @@ -1249,115 +1044,73 @@ public class RAM { return returnValue; } - public synchronized int get_WDT_PrescalerRate() - { + public synchronized int get_WDT_PrescalerRate() { int returnValue = 0; - switch (get_OPTION() & 0b00000111) - { - case 0: - { + switch (get_OPTION() & 0b00000111) { + case 0: { returnValue = 1; }break; - - case 1: - { + case 1: { returnValue = 2; }break; - - case 2: - { + case 2: { returnValue = 4; }break; - - case 3: - { + case 3: { returnValue = 8; }break; - - case 4: - { + case 4: { returnValue = 16; }break; - - case 5: - { + case 5: { returnValue = 32; }break; - - case 6: - { + case 6: { returnValue = 64; }break; - - case 7: - { + case 7: { returnValue = 128; }break; } - return returnValue; } - public synchronized void set_PSA(boolean value) - { + public synchronized void set_PSA(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b00001000; - } - - else - { + } else { option &= 0b11110111; } - set_OPTION(option); } - public synchronized boolean get_PSA() - { - { - return (get_OPTION() & 0b00001000) == 8; - } + public synchronized boolean get_PSA() { + return (get_OPTION() & 0b00001000) == 8; } - public synchronized void set_T0SE(boolean value) - { + public synchronized void set_T0SE(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b00010000; - } - - else - { + } else { option &= 0b11101111; } - set_OPTION(option); } - public synchronized boolean get_T0SE() - { - { - return (get_OPTION() & 0b00010000) == 16; - } + public synchronized boolean get_T0SE() { + return (get_OPTION() & 0b00010000) == 16; } - public synchronized void set_T0CS(boolean value) - { + public synchronized void set_T0CS(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b00100000; - } - - else - { + } else { option &= 0b11011111; } - set_OPTION(option); } @@ -1365,50 +1118,32 @@ public class RAM { return (get_OPTION() & 0b00100000) == 32; } - public synchronized void set_INTEDG(boolean value) - { + public synchronized void set_INTEDG(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b01000000; - } - - else - { + } else { option &= 0b10111111; } - set_OPTION(option); } - public synchronized boolean get_INTEDG() - { - { - return (get_OPTION() & 0b01000000) == 64; - } + public synchronized boolean get_INTEDG() { + return (get_OPTION() & 0b01000000) == 64; } - public synchronized void set_RBPU(boolean value) - { + public synchronized void set_RBPU(boolean value) { int option = get_OPTION(); - if (value) - { + if (value) { option |= 0b10000000; - } - - else - { + } else { option &= 0b01111111; } - set_OPTION(option); } - public synchronized boolean get_RBPU() - { - { - return (get_OPTION() & 0b10000000) == 128; - } + public synchronized boolean get_RBPU() { + return (get_OPTION() & 0b10000000) == 128; } //Bank1 EECON1 @@ -1553,34 +1288,114 @@ public class RAM { return (get_TRISA() & 0b00010000) == 16; } + public synchronized void set_TRISB0(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b00000001; + } else { + trisB &= 0b11111110; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB0() { return (get_TRISB() & 0b00000001) == 1; } + public synchronized void set_TRISB1(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b00000010; + } else { + trisB &= 0b11111101; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB1() { return (get_TRISB() & 0b00000010) == 2; } + public synchronized void set_TRISB2(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b00000100; + } else { + trisB &= 0b11111011; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB2() { return (get_TRISB() & 0b00000100) == 4; } + public synchronized void set_TRISB3(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b00001000; + } else { + trisB &= 0b11110111; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB3() { return (get_TRISB() & 0b00001000) == 8; } + public synchronized void set_TRISB4(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b00010000; + } else { + trisB &= 0b11101111; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB4() { return (get_TRISB() & 0b00010000) == 16; } + public synchronized void set_TRISB5(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b00100000; + } else { + trisB &= 0b11011111; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB5() { return (get_TRISB() & 0b00100000) == 32; } + public synchronized void set_TRISB6(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b01000000; + } else { + trisB &= 0b10111111; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB6() { return (get_TRISB() & 0b01000000) == 64; } + public synchronized void set_TRISB7(boolean value) { + int trisB = get_TRISB(); + if (value) { + trisB |= 0b10000000; + } else { + trisB &= 0b01111111; + } + set_TRISB(trisB); + } + public synchronized boolean get_TRISB7() { return (get_TRISB() & 0b10000000) == 128; } diff --git a/src/Model/Microcontroller/STACK.java b/src/Model/Microcontroller/STACK.java index f450cf1..a794644 100755 --- a/src/Model/Microcontroller/STACK.java +++ b/src/Model/Microcontroller/STACK.java @@ -48,22 +48,20 @@ public class STACK * Pops returnAddress from stack. If stack is empty, throws EmptyStackException. * @return */ - public int popReturnAdressFromStack() - { + public int popReturnAdressFromStack() { int adressToReturn = -1; - if (noObjects(stack)) - { + if (noObjects(stack)) { throw new EmptyStackException(); - } - - else - { + } else { stackpointer--; adressToReturn = stack[stackpointer]; stack[stackpointer] = -1; } + if (stackpointer == -1) + stackpointer = 7; + return adressToReturn; } diff --git a/src/Model/MyModel.java b/src/Model/MyModel.java index d155c80..4d1e13a 100644 --- a/src/Model/MyModel.java +++ b/src/Model/MyModel.java @@ -59,7 +59,7 @@ public class MyModel extends Thread { } //Check if breakpoint is set if (abBreakpoints != null) { - if (!abBreakpoints[oPIC.getRam().get_Programcounter()]) { + if (!abBreakpoints[oPIC.getRam().get_Programcounter()] && !interruptAcknowledged()) { if(iVisualInterval > 0) { try { Thread.sleep(iVisualInterval * 1000); @@ -123,5 +123,16 @@ public class MyModel extends Thread { abBreakpoints = oMyModelData.getBreakpoints(); oPIC.getRuntimer().setQuarzSpeed(oMyModelData.getQuartzInterval()); iVisualInterval = oMyModelData.getVisualInterval(); + qDataToView.add(oPIC); + } + + private boolean interruptAcknowledged() { + boolean bInterruptAcknowledged = false; + + if (oPIC.getRam().get_GIE()) { + + } + + return bInterruptAcknowledged; } }