code: public InputRegister getRegister(int index) {
          if (registers == null) {
              throw new IndexOutOfBoundsException("No registers defined!");
          }
  
          if (index < 0) {
              throw new IndexOutOfBoundsException("Negative index: " + index);
          }
  
          if (index >= getWordCount()) {
              throw new IndexOutOfBoundsException(index + " > " + getWordCount());
          }
  
          return registers[index];
      }
docs: Returns the <tt>Register</tt> at the given position (relative to the
  reference used in the request).
  
  @param index the relative index of the <tt>InputRegister</tt>.
  
  @return the register as <tt>InputRegister</tt>.
  
  @throws IndexOutOfBoundsException if the index is out of bounds.