Update core.py

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