aboutsummaryrefslogtreecommitdiff
path: root/examples/sum-first-odd-integers.eurm
blob: f3e6ddb453d7ec0c4f39687184300280ffecb25c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
COMMENT Compute sum 1 + 3 + 5 + ... + n, where n is the greatest
COMMENT integer less or equal to the initial value of Register 1.

COMMENT Initialization
ZERO 2
INC 2
ZERO 3

COMMENT Main loop
LABEL loop
EQ? 2 1 continue
GEQ? 2 1 done
LABEL continue
ADD 3 2
INC 2
INC 2
GOTO loop

LABEL done
COPY 1 3