write to the correct register