use of brunonova.drmips.simulator.CPU in project drmips by brunonova.
the class DrMIPSActivity method setRegisterValue.
/**
* Updates the value of the register in the indicated row, if editable.
* @param row Row of the register in the table.
* @param value New value of the register.
*/
public void setRegisterValue(int row, int value) {
CPU cpu = getCPU();
if (isRegisterEditable(row)) {
if (row == cpu.getRegBank().getNumberOfRegisters()) {
// PC
if (value % (Data.DATA_SIZE / 8) == 0) {
cpu.setPCAddress(value);
refreshAssembledCodeTable();
refreshDataMemoryTable();
} else
Toast.makeText(DrMIPSActivity.this, R.string.invalid_value, Toast.LENGTH_SHORT).show();
} else if (// register
row >= 0 && row < cpu.getRegBank().getNumberOfRegisters())
cpu.getRegBank().setRegister(row, value);
// update datapath
if (datapath != null)
datapath.refresh();
refreshExecTableValues();
}
}
Aggregations