summary refs log tree commit diff
diff options
context:
space:
mode:
authorQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-08-23 11:44:21 -0400
committerQuentin Carbonneaux <quentin.carbonneaux@yale.edu>2015-09-15 23:01:32 -0400
commit0ad9bf1c602f071a4ae74945d6c751457f9e6f75 (patch)
treecf83ff736fba734cf98691293fa2856fd961ed0b
parent99a8fb67ac30242d4792296c716568b96240db33 (diff)
downloadroux-0ad9bf1c602f071a4ae74945d6c751457f9e6f75.tar.gz
add new prime finding program
-rw-r--r--lisc/test/prime.ssa24
1 files changed, 24 insertions, 0 deletions
diff --git a/lisc/test/prime.ssa b/lisc/test/prime.ssa
new file mode 100644
index 0000000..fd0b05f
--- /dev/null
+++ b/lisc/test/prime.ssa
@@ -0,0 +1,24 @@
+# find the 10,001st prime
+# store it in a
+
+@start
+@loop
+	%n =w phi @start 5, @tloop %n, @yes %n1
+	%p =w phi @start 13, @tloop %p1, @yes %p1
+	%p1 =w add %p, 2
+@tloop
+	%t =w phi @loop 3, @next %t1
+	%r =w rem %p, %t
+	jnz %r, @next, @loop
+@next
+	%t1 =w add 2, %t
+	%tsq =w mul %t1, %t1
+	%c0 =w csgt %tsq, %p
+	jnz %c0, @yes, @tloop
+@yes
+	%n1 =w add 1, %n
+	%c1 =w ceq 10001, %n1
+	jnz %c1, @end, @loop
+@end
+	storew %p, $a
+	ret