diff options
Diffstat (limited to 'examples/sum-first-integers.eurm')
-rw-r--r-- | examples/sum-first-integers.eurm | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/sum-first-integers.eurm b/examples/sum-first-integers.eurm new file mode 100644 index 0000000..0bfae93 --- /dev/null +++ b/examples/sum-first-integers.eurm | |||
@@ -0,0 +1,16 @@ | |||
1 | COMMENT Put in Register 1 the sum 1 + 2 + ... + n, | ||
2 | COMMENT where n is the initial value of Register 1. | ||
3 | |||
4 | COMMENT Initialization | ||
5 | COPY 2 1 | ||
6 | ZERO 3 | ||
7 | |||
8 | COMMENT Main loop | ||
9 | LABEL loop | ||
10 | EQ? 2 3 done | ||
11 | ADD 1 3 | ||
12 | INC 3 | ||
13 | GOTO loop | ||
14 | |||
15 | COMMENT That's all folks ! | ||
16 | LABEL done | ||