Search in sources :

Example 11 with Data

use of brunonova.drmips.simulator.Data in project drmips by brunonova.

the class DrMIPSActivity method refreshDataMemoryTableValues.

/**
	 * Refreshes the values of the registers table.
	 */
public void refreshDataMemoryTableValues() {
    CPU cpu = getCPU();
    if (cpu.hasDataMemory()) {
        TextView address, value;
        TableRow row;
        for (int i = 0; i < cpu.getDataMemory().getMemorySize(); i++) {
            row = (TableRow) tblDataMemory.getChildAt(i + 1);
            address = (TextView) row.getChildAt(0);
            value = (TextView) row.getChildAt(1);
            address.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, i * (Data.DATA_SIZE / 8)), cmbDataMemoryFormat.getSelectedItemPosition()) + " ");
            value.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, cpu.getDataMemory().getDataInIndex(i)), cmbDataMemoryFormat.getSelectedItemPosition()));
            // Highlight memory positions being accessed
            int index = cpu.getDataMemory().getAddress().getValue() / (Data.DATA_SIZE / 8);
            boolean read = cpu.getDataMemory().getMemRead().getValue() == 1;
            boolean write = cpu.getDataMemory().getMemWrite().getValue() == 1;
            if (write && i == index) {
                if (read)
                    row.setBackgroundColor(Util.getThemeColor(this, R.attr.rwColor));
                else
                    row.setBackgroundColor(Util.getThemeColor(this, R.attr.writeColor));
            } else if (read && i == index)
                row.setBackgroundColor(Util.getThemeColor(this, R.attr.readColor));
            else
                // remove background color
                row.setBackgroundResource(0);
        }
        tblDataMemory.requestLayout();
    }
}
Also used : TableRow(android.widget.TableRow) CPU(brunonova.drmips.simulator.CPU) TextView(android.widget.TextView) Data(brunonova.drmips.simulator.Data)

Aggregations

Data (brunonova.drmips.simulator.Data)11 JSONObject (org.json.JSONObject)7 TableRow (android.widget.TableRow)2 TextView (android.widget.TextView)2 AssembledInstruction (brunonova.drmips.simulator.AssembledInstruction)2 CPU (brunonova.drmips.simulator.CPU)2 JSONArray (org.json.JSONArray)1