forked from algorithm-archivists/algorithm-archive
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheuclidian_mod_comments.ws
32 lines (30 loc) · 1.14 KB
/
euclidian_mod_comments.ws
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
Reading the input: a, b
[SPACE][SPACE][SPACE][LF] push 0
[SPACE][SPACE][SPACE][TAB][LF] push 1
[TAB][LF][TAB][TAB] readi
[TAB][LF][TAB][TAB] readi
Loop: a, b => b, a%b
[LF][SPACE][SPACE][LF] label_0:
[SPACE][SPACE][SPACE][LF] push 0
[TAB][TAB][TAB] retrieve
[SPACE][LF][SPACE] dup
[LF][TAB][SPACE][TAB][LF] jmp zero label_1
[SPACE][SPACE][SPACE][TAB][LF] push 1
[TAB][TAB][TAB] retrieve
[SPACE][LF][TAB] swap
[TAB][SPACE][TAB][TAB] mod
[SPACE][SPACE][SPACE][LF] push 0
[TAB][TAB][TAB] retrieve
[SPACE][SPACE][SPACE][TAB][LF] push 1
[SPACE][LF][TAB] swap
[TAB][TAB][SPACE] store
[SPACE][SPACE][SPACE][LF] push 0
[SPACE][LF][TAB] swap
[TAB][TAB][SPACE] store
[LF][SPACE][LF][LF] jmp label_0
Exit when b=0
[LF][SPACE][SPACE][TAB][LF] label_1:
[SPACE][SPACE][SPACE][TAB][LF] push 1
[TAB][TAB][TAB] retrieve
[TAB][LF][SPACE][TAB] printi
[LF][LF][LF][LF] end