diff options
author | pacien | 2018-04-30 23:21:17 +0200 |
---|---|---|
committer | pacien | 2018-04-30 23:21:17 +0200 |
commit | 37716a32c9aadcca83746bf96bf32b552fa55847 (patch) | |
tree | 0863035615645c376f3e7fa85d6b4b8de2354e84 /examples/sum-first-odd-integers.eurm | |
parent | 720ffc02dc4d8614b1f8c3c31dd161984b1c6642 (diff) | |
download | urm-37716a32c9aadcca83746bf96bf32b552fa55847.tar.gz |
Add examples from S.V website
Diffstat (limited to 'examples/sum-first-odd-integers.eurm')
-rw-r--r-- | examples/sum-first-odd-integers.eurm | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/examples/sum-first-odd-integers.eurm b/examples/sum-first-odd-integers.eurm new file mode 100644 index 0000000..f3e6ddb --- /dev/null +++ b/examples/sum-first-odd-integers.eurm | |||
@@ -0,0 +1,20 @@ | |||
1 | COMMENT Compute sum 1 + 3 + 5 + ... + n, where n is the greatest | ||
2 | COMMENT integer less or equal to the initial value of Register 1. | ||
3 | |||
4 | COMMENT Initialization | ||
5 | ZERO 2 | ||
6 | INC 2 | ||
7 | ZERO 3 | ||
8 | |||
9 | COMMENT Main loop | ||
10 | LABEL loop | ||
11 | EQ? 2 1 continue | ||
12 | GEQ? 2 1 done | ||
13 | LABEL continue | ||
14 | ADD 3 2 | ||
15 | INC 2 | ||
16 | INC 2 | ||
17 | GOTO loop | ||
18 | |||
19 | LABEL done | ||
20 | COPY 1 3 | ||