1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
mov tortoise $0 mov hare $0 mov cycle_found $0 label loop ; tortise = tortoise->next load tortoise tortoise ; hare = hare->next->next load hare hare load hare hare ; are_eq = (tortoise == hare) mov are_eq tortoise eq are_eq hare ; cycle found? ite are_eq cycle loop label cycle mov cycle_found $1 end