summaryrefslogtreecommitdiff
path: root/example/test_files/cycle
blob: e5fc1d364ae737da62f14da7f2daef8d734cb158 (plain)
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
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback