Writhing dynamics of cables with self-contact