Search in sources :

Example 11 with CPU

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();
    }
}
Also used : CPU(brunonova.drmips.simulator.CPU)

Aggregations

CPU (brunonova.drmips.simulator.CPU)11 TextView (android.widget.TextView)8 TableRow (android.widget.TableRow)7 DrMIPSActivity (brunonova.drmips.android.DrMIPSActivity)2 Data (brunonova.drmips.simulator.Data)2 SuppressLint (android.annotation.SuppressLint)1 SharedPreferences (android.content.SharedPreferences)1 View (android.view.View)1 TableLayout (android.widget.TableLayout)1 AssembledInstruction (brunonova.drmips.simulator.AssembledInstruction)1 Instruction (brunonova.drmips.simulator.Instruction)1 PseudoInstruction (brunonova.drmips.simulator.PseudoInstruction)1