Compare commits
2 Commits
incrementP
...
guiSRAM
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
43e79778fe | ||
|
|
7ef8a285e0 |
@@ -2,9 +2,11 @@ package de.darkress.pic16f84sim;
|
|||||||
|
|
||||||
import de.darkress.pic16f84sim.commands.Command;
|
import de.darkress.pic16f84sim.commands.Command;
|
||||||
import de.darkress.pic16f84sim.decoder.CommandDecoder;
|
import de.darkress.pic16f84sim.decoder.CommandDecoder;
|
||||||
|
import de.darkress.pic16f84sim.gui.SramTable;
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
class Main
|
class Main
|
||||||
@@ -19,5 +21,14 @@ class Main
|
|||||||
{
|
{
|
||||||
program.get(ProgramCounter.getPc()).execute();
|
program.get(ProgramCounter.getPc()).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SramTable table = new SramTable();
|
||||||
|
JFrame frame = new JFrame("Table Example");
|
||||||
|
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||||
|
frame.add(table.getTable());
|
||||||
|
frame.pack();
|
||||||
|
frame.setVisible(true);
|
||||||
|
//table.setValueAt("test", 15, 7);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package de.darkress.pic16f84sim.commands;
|
package de.darkress.pic16f84sim.commands;
|
||||||
|
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
|
||||||
|
|
||||||
public class Andlw extends LiteralCommandUtils implements Command
|
public class Andlw extends LiteralCommandUtils implements Command
|
||||||
{
|
{
|
||||||
@@ -19,6 +18,5 @@ public class Andlw extends LiteralCommandUtils implements Command
|
|||||||
checkZeroBit(result);
|
checkZeroBit(result);
|
||||||
|
|
||||||
Memory.workingRegister = result % 256;
|
Memory.workingRegister = result % 256;
|
||||||
ProgramCounter.incPC();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public class Decfsz extends FileRegisterCommandUtils implements Command
|
|||||||
|
|
||||||
if((result % 256) == 0)
|
if((result % 256) == 0)
|
||||||
{
|
{
|
||||||
ProgramCounter.incPC();
|
Nop nop = new Nop();
|
||||||
|
nop.execute(); // TODO: What happens if an interrupt gets triggered during the nop execution?
|
||||||
}
|
}
|
||||||
ProgramCounter.incPC();
|
ProgramCounter.incPC();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,8 @@ public class Incfsz extends FileRegisterCommandUtils implements Command
|
|||||||
|
|
||||||
if((result % 256) == 0)
|
if((result % 256) == 0)
|
||||||
{
|
{
|
||||||
ProgramCounter.incPC();
|
Nop nop = new Nop();
|
||||||
|
nop.execute(); // TODO: What happens if an interrupt gets triggered during the nop execution?
|
||||||
}
|
}
|
||||||
ProgramCounter.incPC();
|
ProgramCounter.incPC();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package de.darkress.pic16f84sim.commands;
|
package de.darkress.pic16f84sim.commands;
|
||||||
|
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
|
||||||
|
|
||||||
public class Iorlw extends LiteralCommandUtils implements Command
|
public class Iorlw extends LiteralCommandUtils implements Command
|
||||||
{
|
{
|
||||||
@@ -19,6 +18,5 @@ public class Iorlw extends LiteralCommandUtils implements Command
|
|||||||
checkZeroBit(result);
|
checkZeroBit(result);
|
||||||
|
|
||||||
Memory.workingRegister = result % 256;
|
Memory.workingRegister = result % 256;
|
||||||
ProgramCounter.incPC();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package de.darkress.pic16f84sim.commands;
|
package de.darkress.pic16f84sim.commands;
|
||||||
|
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
|
||||||
|
|
||||||
public class Sublw extends LiteralCommandUtils implements Command
|
public class Sublw extends LiteralCommandUtils implements Command
|
||||||
{
|
{
|
||||||
@@ -42,6 +41,5 @@ public class Sublw extends LiteralCommandUtils implements Command
|
|||||||
checkDigitCarryBit(literal);
|
checkDigitCarryBit(literal);
|
||||||
|
|
||||||
Memory.workingRegister = result % 256;
|
Memory.workingRegister = result % 256;
|
||||||
ProgramCounter.incPC();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
package de.darkress.pic16f84sim.commands;
|
package de.darkress.pic16f84sim.commands;
|
||||||
|
|
||||||
import de.darkress.pic16f84sim.microcontroller.Memory;
|
import de.darkress.pic16f84sim.microcontroller.Memory;
|
||||||
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
|
|
||||||
|
|
||||||
public class Xorlw extends LiteralCommandUtils implements Command
|
public class Xorlw extends LiteralCommandUtils implements Command
|
||||||
{
|
{
|
||||||
@@ -19,6 +18,5 @@ public class Xorlw extends LiteralCommandUtils implements Command
|
|||||||
checkZeroBit(result);
|
checkZeroBit(result);
|
||||||
|
|
||||||
Memory.workingRegister = result % 256;
|
Memory.workingRegister = result % 256;
|
||||||
ProgramCounter.incPC();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
52
de/darkress/pic16f84sim/gui/SramTable.java
Normal file
52
de/darkress/pic16f84sim/gui/SramTable.java
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
package de.darkress.pic16f84sim.gui;
|
||||||
|
|
||||||
|
import javax.swing.*;
|
||||||
|
import java.awt.*;
|
||||||
|
import java.awt.geom.Dimension2D;
|
||||||
|
|
||||||
|
public class SramTable
|
||||||
|
{
|
||||||
|
private final int rows = 32;
|
||||||
|
private final int columns = 8;
|
||||||
|
private Object[][] data = new Object[rows][columns];
|
||||||
|
|
||||||
|
public JTable getTable()
|
||||||
|
{
|
||||||
|
return table;
|
||||||
|
}
|
||||||
|
|
||||||
|
private JTable table = new JTable(data, createColumns());
|
||||||
|
|
||||||
|
public SramTable()
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
for (int i = 0; i < rows; i++) {
|
||||||
|
for (int j = 0; j < columns; j++) {
|
||||||
|
data[i][j] = Integer.toHexString(count).toUpperCase();
|
||||||
|
table.getColumnModel().getColumn(j).setPreferredWidth(30);
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object[] createColumns(){
|
||||||
|
Object[] columnNames = new Object[columns];
|
||||||
|
for (int j = 0; j < columns; j++) {
|
||||||
|
columnNames[j] = j;
|
||||||
|
}
|
||||||
|
return columnNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public void table() {
|
||||||
|
// Create a scroll pane and add the table to it
|
||||||
|
JScrollPane scrollPane = new JScrollPane(table);
|
||||||
|
|
||||||
|
// Create a panel and add the scroll pane to it
|
||||||
|
JPanel panel = new JPanel();
|
||||||
|
panel.add(scrollPane);
|
||||||
|
|
||||||
|
// Create a frame and add the panel to it
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user