Update core.py

The index should be less than the length of registers list, or a IndexError will be thrown