aboutsummaryrefslogtreecommitdiff
path: root/examples/even.eurm
diff options
context:
space:
mode:
Diffstat (limited to 'examples/even.eurm')
-rw-r--r--examples/even.eurm25
1 files changed, 25 insertions, 0 deletions
diff --git a/examples/even.eurm b/examples/even.eurm
new file mode 100644
index 0000000..f07ad37
--- /dev/null
+++ b/examples/even.eurm
@@ -0,0 +1,25 @@
1COMMENT Decide wether the content of Register 1 is even.
2COMMENT The output is 0 if it is even and 1 otherwise
3
4COMMENT initialization
5ZERO 2
6
7COMMENT main loop
8LABEL loop
9COMMENT invariant: R2 is even
10EQ? 1 2 even
11INC 2
12COMMENT invariant: R2 is odd
13EQ? 1 2 odd
14INC 2
15GOTO loop
16
17COMMENT R1 holds an even number
18LABEL even
19ZERO 1
20QUIT
21
22COMMENT R1 holds an odd number
23LABEL odd
24ZERO 1
25INC 1