diff options
Diffstat (limited to 'examples/even.eurm')
-rw-r--r-- | examples/even.eurm | 25 |
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 @@ | |||
1 | COMMENT Decide wether the content of Register 1 is even. | ||
2 | COMMENT The output is 0 if it is even and 1 otherwise | ||
3 | |||
4 | COMMENT initialization | ||
5 | ZERO 2 | ||
6 | |||
7 | COMMENT main loop | ||
8 | LABEL loop | ||
9 | COMMENT invariant: R2 is even | ||
10 | EQ? 1 2 even | ||
11 | INC 2 | ||
12 | COMMENT invariant: R2 is odd | ||
13 | EQ? 1 2 odd | ||
14 | INC 2 | ||
15 | GOTO loop | ||
16 | |||
17 | COMMENT R1 holds an even number | ||
18 | LABEL even | ||
19 | ZERO 1 | ||
20 | QUIT | ||
21 | |||
22 | COMMENT R1 holds an odd number | ||
23 | LABEL odd | ||
24 | ZERO 1 | ||
25 | INC 1 | ||