Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
41 lines (36 sloc) 1.67 KB
set a 1
set b 108400
set c 125400
set d 1
set e 108400
set f 0
set g 0
set h 0
set d 4 [via sub d -1]
set g -108396 [via set g d and sub g b]
set e 2 ^^^[e becomes 2]
set g d *** [g becomes 4] {g becomes d}
mul g e [g becomes 8]...[g becomes 4*e] {g becomes e*d}
sub g b [g becomes -108392]...[g becomes 4*e-b] {g becomes d*e - b}
jnz g 2 [jump!]... {jump when [d*e - b] != 0}
set f 0 ~~~key!~~~
sub e -1 [e becomes 3]...[e becomes 108400] {g becomes b}
set g e [g becomes 3]...[g becomes 108400] {g becomes b}
sub g b [g becomes -108397]...[g becomes 0] {g becomes 0}
jnz g -8 [jump!] *** {keep jumping until e becomes b}
sub d -1
set g d
sub g b
jnz g -13 [jump!]^^^ {we have to keep doing this until d becomes b}
jnz f 2 [jump if f was NOT set to zero above]
sub h -1 [h maybe decreases by 1??]
set g b [g becomes 108400]
sub g c [g becomes 125400]
jnz g 2 [jump!] {when g is zero we quit; g is zero when b is equal to c}
jnz 1 3
sub b -17 [b becomes 17 more, 108417]
jnz 1 -23 [jump back to set f 1, set e 2 and set g d, do it all over again until g is finally zero!]
each major iteration, b increases by 17 and c stays the same
we need (b - 125400) = 0 or b = 125400
b starts at 108400, which means we need (125400-108400)/17 = 10000 iterations
we subtract 1 from h any time f is zero, but can it ever be not zero??