use of brunonova.drmips.simulator.AssembledInstruction in project drmips by brunonova.
the class DrMIPSActivity method refreshAssembledCodeTable.
/**
* Refreshes the contents of the code table.
*/
private void refreshAssembledCodeTable() {
while (// remove all rows except header
tblAssembledCode.getChildCount() > 1) tblAssembledCode.removeViewAt(1);
AssembledInstruction instruction;
TableRow row;
TextView address, assembled, code;
String codeLine;
CPU cpu = getCPU();
for (int i = 0; i < cpu.getInstructionMemory().getNumberOfInstructions(); i++) {
instruction = cpu.getInstructionMemory().getInstruction(i);
row = new TableRow(this);
row.setOnClickListener(assembledCodeRowOnClickListener);
address = new TextView(this);
address.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, i * (Data.DATA_SIZE / 8)), cmbAssembledCodeFormat.getSelectedItemPosition()) + " ");
address.setTextAppearance(this, android.R.style.TextAppearance_Medium);
address.setTypeface(Typeface.MONOSPACE);
assembled = new TextView(this);
assembled.setText(Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, instruction.getData().getValue()), cmbAssembledCodeFormat.getSelectedItemPosition()) + " ");
assembled.setTextAppearance(this, android.R.style.TextAppearance_Medium);
assembled.setTypeface(Typeface.MONOSPACE);
code = new TextView(this);
codeLine = instruction.getLineNumber() + ": ";
for (String label : instruction.getLabels()) codeLine += label + ": ";
codeLine += instruction.getCodeLine();
code.setText(codeLine);
code.setTextAppearance(this, android.R.style.TextAppearance_Medium);
code.setTypeface(Typeface.MONOSPACE);
row.addView(address);
row.addView(assembled);
row.addView(code);
tblAssembledCode.addView(row);
}
refreshAssembledCodeTableValues();
}
use of brunonova.drmips.simulator.AssembledInstruction in project drmips by brunonova.
the class AssembledCodeTable method refresh.
/**
* Refresh the values in the table.
* @param format The data format (<tt>Util.BINARYL_FORMAT_INDEX/v.DECIMAL_FORMAT_INDEX/Util.HEXADECIMAL_FORMAT_INDEX</tt>).
*/
public void refresh(int format) {
AssembledInstruction instruction;
Object[] data;
dataFormat = format;
model.setRowCount(0);
for (int i = 0; i < cpu.getInstructionMemory().getNumberOfInstructions(); i++) {
instruction = cpu.getInstructionMemory().getInstruction(i);
data = new Object[3];
data[0] = Util.formatDataAccordingToFormat(new Data(Data.DATA_SIZE, i * (Data.DATA_SIZE / 8)), format);
data[1] = Util.formatDataAccordingToFormat(instruction.getData(), format);
data[2] = instruction.getLineNumber() + ": ";
for (String label : instruction.getLabels()) data[2] += label + ": ";
data[2] += instruction.getCodeLine();
model.addRow(data);
}
refreshValues();
}
Aggregations