1## Structured VM: VM assembly example: Greatest Common Divisor, optimized.
2
3## Copyright (C) 2019 Luca Saiu
4## Written by Luca Saiu
5
6## This file is part of Jitter.
7
8## Jitter is free software: you can redistribute it and/or modify
9## it under the terms of the GNU General Public License as published by
10## the Free Software Foundation, either version 3 of the License, or
11## (at your option) any later version.
12
13## Jitter is distributed in the hope that it will be useful,
14## but WITHOUT ANY WARRANTY; without even the implied warranty of
15## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16## GNU General Public License for more details.
17
18## You should have received a copy of the GNU General Public License
19## along with Jitter.  If not, see <http://www.gnu.org/licenses/>. */
20
21
22        set-r            3333333333, %r0
23        set-r            1, %r1
24$L4:
25        pushr-beqr       %r0, %r1, $L22
26        pushr-bger       %r0, %r1, $L17
27        pushr-minusr-pop %r1, %r0, %r1
28        b                $L21
29$L17:
30        pushr-minusr-pop %r0, %r1, %r0
31$L21:
32        b                $L4
33$L22:
34        push             %r0
35        print
36