summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsiddharth <s@ricketyspace.net>2018-01-03 00:13:49 +0000
committerrsiddharth <s@ricketyspace.net>2018-01-03 00:13:49 +0000
commit522559167afd0ff4818cf7929d209063e3baae68 (patch)
treeffccabd397d5991694f44642f7ca78ed5d37686e
parentca8dc1eaf03dcc64d8c72029d17d04e2e7b50e61 (diff)
Add mix/1.3.2/prime.mixal.
-rw-r--r--mix/1.3.2/prime.mixal52
1 files changed, 52 insertions, 0 deletions
diff --git a/mix/1.3.2/prime.mixal b/mix/1.3.2/prime.mixal
new file mode 100644
index 0000000..12a56bb
--- /dev/null
+++ b/mix/1.3.2/prime.mixal
@@ -0,0 +1,52 @@
+* EXAMPLE PROGRAM ... TABLE OF PRIMES
+*
+L EQU 500 The number of primes to find
+PRINTER EQU 18 Unit number of the line printer
+PRIME EQU -1 Memory area of table of primes
+BUF0 EQU 2000 Memory area for BUFFER[0]
+BUF1 EQU BUF0+25 Memory area for BUFFER[1]
+ ORIG 3000
+START IOC 0(PRINTER) Skip to new page.
+ LD1 =1-L= P1. Start table. J <- 1.
+ LD2 =3= N <- 3.
+2H INC1 1 P2. N is prime. J <- J + 1.
+ ST2 PRIME+L,1 PRIME[J] <- N.
+ J1Z 2F P3. 500 found?
+4H INC2 2 P4. Advance N.
+ ENT3 2 P5. K <- 2.
+6H ENTA 0 P6. PRIME[K]\N?
+ ENTX 0,2 rAX <- N.
+ DIV PRIME,3 rA <- Q, rX <- R.
+ JXZ 4B To P4 if R = 0.
+ CMPA PRIME,3 P7. PRIME[K] large?
+ INC3 1 P8. Advance K.
+ JG 6B To P6 if Q > PRIME[K].
+ JMP 2B Otherwise N is prime.
+2H OUT TITLE(PRINTER) P9. Print title.
+ ENT4 BUF1+10 Set B <- 1.
+ ENT5 -50 Set M <- 0.
+2H INC5 L+1 Advance M.
+4H LDA PRIME,5 P10. Set up line. (Right to left)
+ CHAR 0 Convert PRIME[M] to decimal.
+ STX 0,4(1:4)
+ DEC4 1
+ DEC5 50 (rI5 goes down by 50 until
+ J5P 4B it becomes nonpositive)
+ OUT 0,4(PRINTER) P11. Print line.
+ LD4 24,4 Switch buffers.
+ J5N 2B If rI5 = 0, we are done.
+ HLT
+* INITIAL CONTENTS OF TABLES AND BUFFERS
+ ORIG PRIME+1
+ CON 2
+ ORIG BUF0-5
+TITLE ALF "FIRST"
+ ALF " FIVE"
+ ALF " HUND"
+ ALF "RED P"
+ ALF "RIMES"
+ ORIG BUF0+24
+ CON BUF1+10
+ ORIG BUF1+24
+ CON BUF0+10
+ END START