Example #1
0
    def execute(self, registers: Registers, program_counter, memory: Memory,
                *args, **kwargs):
        rs_register = registers.get_register(self.rs_number)
        new_pc = rs_register.to_unsigned_int()

        branch_delayed_word = memory.load(program_counter + 4)
        branch_delayed_instruction = kwargs['instruction_factory'].factory(
            branch_delayed_word)
        delayed_registers, delayed_pc, delayed_memory, coproc = branch_delayed_instruction.execute(
            registers=registers,
            program_counter=program_counter + 4,
            memory=memory,
            *args,
            **kwargs)

        return delayed_registers, new_pc, delayed_memory, kwargs[
            'coprocessor'].registers
Example #2
0
 def test_get_all_valid_registers(self):
     registers = Registers()
     for x in range(32):
         register = registers.get_register(x)
         assert isinstance(register, Register)
Example #3
0
 def test_get_invalid_register(self):
     registers = Registers()
     with pytest.raises(InvalidRegister):
         registers.get_register(-1)
         registers.registers(100)