Compare commits

..

2 Commits

Author SHA1 Message Date
Darkress
43e79778fe Set column width 2023-06-08 02:15:37 +02:00
Darkress
7ef8a285e0 test table 2023-06-07 22:05:38 +02:00
8 changed files with 67 additions and 10 deletions

View File

@@ -2,9 +2,11 @@ package de.darkress.pic16f84sim;
import de.darkress.pic16f84sim.commands.Command;
import de.darkress.pic16f84sim.decoder.CommandDecoder;
import de.darkress.pic16f84sim.gui.SramTable;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
import javax.swing.*;
import java.util.ArrayList;
class Main
@@ -19,5 +21,14 @@ class Main
{
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);
}
}

View File

@@ -1,7 +1,6 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Andlw extends LiteralCommandUtils implements Command
{
@@ -19,6 +18,5 @@ public class Andlw extends LiteralCommandUtils implements Command
checkZeroBit(result);
Memory.workingRegister = result % 256;
ProgramCounter.incPC();
}
}

View File

@@ -25,7 +25,8 @@ public class Decfsz extends FileRegisterCommandUtils implements Command
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();
}

View File

@@ -25,7 +25,8 @@ public class Incfsz extends FileRegisterCommandUtils implements Command
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();
}

View File

@@ -1,7 +1,6 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Iorlw extends LiteralCommandUtils implements Command
{
@@ -19,6 +18,5 @@ public class Iorlw extends LiteralCommandUtils implements Command
checkZeroBit(result);
Memory.workingRegister = result % 256;
ProgramCounter.incPC();
}
}

View File

@@ -1,7 +1,6 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Sublw extends LiteralCommandUtils implements Command
{
@@ -42,6 +41,5 @@ public class Sublw extends LiteralCommandUtils implements Command
checkDigitCarryBit(literal);
Memory.workingRegister = result % 256;
ProgramCounter.incPC();
}
}

View File

@@ -1,7 +1,6 @@
package de.darkress.pic16f84sim.commands;
import de.darkress.pic16f84sim.microcontroller.Memory;
import de.darkress.pic16f84sim.microcontroller.ProgramCounter;
public class Xorlw extends LiteralCommandUtils implements Command
{
@@ -19,6 +18,5 @@ public class Xorlw extends LiteralCommandUtils implements Command
checkZeroBit(result);
Memory.workingRegister = result % 256;
ProgramCounter.incPC();
}
}

View 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
}
}