Skip to content

Commit bb3eac2

Browse files
committed
updating euclidean_algorithm.md
1 parent a9c3c3e commit bb3eac2

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

contents/euclidean_algorithm/euclidean_algorithm.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ The algorithm is a simple way to find the *greatest common divisor* (GCD) of two
3939
[import:1-10, lang="julia"](code/julia/euclidean.jl)
4040
{% sample lang="nim" %}
4141
[import:13-24, lang="nim"](code/nim/euclid_algorithm.nim)
42+
{% sample lang="x86asm" %}
43+
[import:43-78, lang="x86asm"](code/x86asm/euclidean_example.asm)
4244
{% endmethod %}
4345

4446
Here, we simply line the two numbers up every step and subtract the lower value from the higher one every timestep. Once the two values are equal, we call that value the greatest common divisor. A graph of `a` and `b` as they change every step would look something like this:
@@ -84,6 +86,8 @@ Modern implementations, though, often use the modulus operator (%) like so
8486
[import:12-25, lang="julia"](code/julia/euclidean.jl)
8587
{% sample lang="nim" %}
8688
[import:1-11, lang="nim"](code/nim/euclid_algorithm.nim)
89+
{% sample lang="x86asm" %}
90+
[import:8-41, lang="x86asm"](code/x86asm/euclidean_example.asm)
8791
{% endmethod %}
8892

8993
Here, we set `b` to be the remainder of `a%b` and `a` to be whatever `b` was last timestep. Because of how the modulus operator works, this will provide the same information as the subtraction-based implementation, but when we show `a` and `b` as they change with time, we can see that it might take many fewer steps:
@@ -134,6 +138,8 @@ The Euclidean Algorithm is truly fundamental to many other algorithms throughout
134138
[import, lang="julia"](code/julia/euclidean.jl)
135139
{% sample lang="nim" %}
136140
[import, lang="nim" %](code/nim/euclid_algorithm.nim)
141+
{% sample lang="x86asm" %}
142+
[import, lang="x86asm"](code/x86asm/euclidean_example.asm)
137143
{% endmethod %}
138144

139145

0 commit comments

Comments
 (0)