<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def register_write(self, reg_index, value):
 """Writes into an ARM register. Note: The data is not immediately written, but is cached before being transferred to the CPU on CPU start. Args: self (JLink):
 the ``JLink`` instance reg_index (int):
 the ARM register to write to value (int):
 the value to write to the register Returns: The value written to the ARM register. Raises: JLinkException: on write error. """

        res = self._dll.JLINKARM_WriteReg(reg_index, value)
        if res != 0:
            raise errors.JLinkException('Error writing to register %d' % reg_index)
        return value