aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--examples/factorial.eurm23
-rw-r--r--examples/factorial.reg1
2 files changed, 24 insertions, 0 deletions
diff --git a/examples/factorial.eurm b/examples/factorial.eurm
new file mode 100644
index 0000000..f22cc19
--- /dev/null
+++ b/examples/factorial.eurm
@@ -0,0 +1,23 @@
1COMMENT compute |R1| ! and place the result in register R1.
2ZERO? 1 R1=0
3GOTO R1>0
4COMMENT R1=0, we are done as 0 ! = 1.
5LABEL R1=0
6INC 1
7GOTO done
8COMMENT R1>0, use n ! = 1 x 2 x ... x n
9LABEL R1>0
10COPY 2 1
11ZERO 1
12INC 1
13ZERO 3
14INC 3
15COMMENT main loop
16LABEL loop
17MULT 1 3
18EQ? 2 3 done
19INC 3
20GOTO loop
21COMMENT that’s all folks.
22LABEL done
23QUIT
diff --git a/examples/factorial.reg b/examples/factorial.reg
new file mode 100644
index 0000000..0d6a524
--- /dev/null
+++ b/examples/factorial.reg
@@ -0,0 +1 @@
1 5