shithub: riscv

ref: c76cc12a1799ce214b07882eb6f4ab0906c0151b
dir: /sys/src/games/mix/examples/primes.m/

View raw version
* EXAMPLE PROGRAM ... TABLE OF PRIMES
*
L	EQU	500
PRINTER	EQU	18
PRIME	EQU	-1
BUF0	EQU	2000
BUF1	EQU	BUF0+25
	ORIG	3000
START	IOC	0(PRINTER)
	LD1	=1-L=
	LD2	=3=
2H	INC1	1
	ST2	PRIME+L,1
	J1Z	2F
4H	INC2	2
	ENT3	2
6H	ENTA	0
	ENTX	0,2
	DIV	PRIME,3
	JXZ	4B
	CMPA	PRIME,3
	INC3	1
	JG	6B
	JMP	2B
2H	OUT	TITLE(PRINTER)
	ENT4	BUF1+10
	ENT5	-50
2H	INC5	L+1
4H	LDA	PRIME,5
	CHAR
	STX	0,4(1:4)
	DEC4	1
	DEC5	50
	J5P	4B
	OUT	0,4(PRINTER)
	LD4	24,4
	J5N	2B
	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