From 37716a32c9aadcca83746bf96bf32b552fa55847 Mon Sep 17 00:00:00 2001 From: pacien Date: Mon, 30 Apr 2018 23:21:17 +0200 Subject: Add examples from S.V website --- examples/sum-first-integers.eurm | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 examples/sum-first-integers.eurm (limited to 'examples/sum-first-integers.eurm') 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 @@ +COMMENT Put in Register 1 the sum 1 + 2 + ... + n, +COMMENT where n is the initial value of Register 1. + +COMMENT Initialization +COPY 2 1 +ZERO 3 + +COMMENT Main loop +LABEL loop +EQ? 2 3 done +ADD 1 3 +INC 3 +GOTO loop + +COMMENT That's all folks ! +LABEL done -- cgit v1.2.3