|tx0 to pdp1 program 4-3-70
|p 1
|text writer macro
|call write 6message9
|includes subroutine wr

define write a
	define write c|d
	tsx wr
	d-.-2
	text |c|
d,	terminate write
	write 6a9
	tra zzxgwq
wr,	llx 0
	ixl
lpkh,	ixl
	lax 1
	aux .-1
	pnt
	pnt
	prtUixl
	tix lpkh
	ixl
	trx 1
zzxgwq,	terminate

|p 2
|bit shuffler
|10-12-69 mse
|displays data on crt
| input conversion shufl or shufli
|output shuflo
|call tsx name with number in ac, ans in lr

shufl=shufli

shufli,	sxa sret
	ldx (sbitsi
	sxa slax
	tra shufq

shuflo,	sxa sret
	ldx (sbitso
	sxa slax
shufq,
	lro
	ldx (17.
slp,	disUcyr
	trn sneg
	tra slpx
sneg,	sto Asto
slax,	lax sbitsi	|or sbitso
	orl
	lda asto
slpx,	tix slp
sret,	tra .


sbitsi,	000040
	004000
	400000
	000020
	002000
	200000
	000010
	001000
	100000
	000004
	000400
	040000
	000002
	000200
	020000
	000001
	000100
	010000

sbitso,	100000
	010000
	001000
	000100
	000010
	000001
	200000
	020000
	002000
	000200
	000020
	000002
	100000
	010000
	001000
	000100
	000010
	000001



variables
constants
|p 3
|var leng tape read
|10-12-69 mse
|call tsx read
|  first core locn
|  max length of record expected
|  error returns here
|  normal exit here

read,	rtb 1
	cpf
	lax 0	|first locn of xfer
	llx 1	|length
	aux (2
	sxa rerrx
	aux (1
	sxa readx	|return adr
	lad	|last adr+1
	axr	|into xr
	tix .+1	|sub 1
	sxa rput	|last adr
	lcc	|-lr to ac (=-wd cnt)
	axo	|ac to xr, 0 to ac
	stz rcntq
	tra rlend

rcpy,	cpy
rput,	slx .
	rpf
	tze rtally
	tra rchk
rtally,	ado Rcntq
rlend,	tix rcpy

rchk,	llr (16000	|no eor flg
	rpf+7
	tze readx
	tsx .+1
rerrx,	tra .	|error return
readx,	tra .

variables
constants
|p 4
|octal print macro

define opt a
	lda a
	tsx opte
	terminate

|octal print
|leading zeroes suppressed to blanks
|call tsx opte with number in ac

opte,	sxa optx
	sto Otem
	lda (character r 	|blank instead of zero
	sto onum
	llr (7
	ldx (4
olp,	sxa Oix
	lda otem
	cyl
	cyl
	cyl
	sto otem
	ana
	axr
	tze oblnk
	lda (character r0
	sto onum	|restore 0
oblnk,	lax onum
	prt
	ldx oix
	tix olp
	lda (character r0
	sto onum
	lda otem
	repeat 3, cyl	
	ana
	axr
	lax onum
	prt
optx,	tra .

onum,	text .000111222333444555666777.

variables
constants
|p 5
|decimal print page 1
|dpt macro
|using dconv, dcwr
|defines dcparr on first call

define dpt a

	dimension dcparr(7)
	define dpt a
		lda a
		tsx dconv
		dcparr
		tsx dcwr
		dcparr
		terminate
	dpt a
	terminate


define carrig
	lda (101001
	prt
	terminate

define tab
	lda (100101
	prt
	terminate

|p 6
|dpt page 2 decimal convert
|output in 7 element array:
|1-  + or - character
|2-7 binary number giving no. of decimal digit (0-9)
|mse 12-18-69

|call   tsx dconv
|       address	|dimension address(7)

dconv,	llx
	slr Doutad
	aux (1
	sxa dcex
	trn dcneg
	alo
	lda (character r+
	tra dcsgn
dcneg,	com
	alo	|-ac to lr, 0 to ac
	lda (character r-
dcsgn,	ldx doutad
	stx	|store sign
	aux (1
	sxa doutad
	lac
	ldx (-5
dclp,	stz Temp
dclp1,	alr
	adx dcarr+5
	tze .+2
	trn dcov
	alr
	ado Temp
	lac
	tra dclp1
dcov,	xac
	sto Temp1
	aux doutad
	lda temp
	stx 5	|store digit
	ldx temp1
	lac
	tix dclp
dcex,	tra .

dcarr,	-100000.	-10000.	-1000.	-100.	-10.
	-1.

variables
constants

|p 7
|dpt page 3 dec. writer
|zero and sign suppression

|call  tsx dcwr
|      address

dcwr,	llx
	slr doutaD
	aux (1
	sxa dcwrx
	lda (tze dcwlx-1	|switch on zero sup.
	sto dcws
	lxr
	lax	|+ or - char in ac
	alr
	add (-character r+
	tze .+3	|suppress + sign
	lac
	prt
	aux (1
	sxa doutad
	ldx (-4
dcwlp,	xac
	sto Temp
	aux doutad
	lax 4	|no. to ac
dcws,	.	|tze or nop
	axr
	lda (nop
	sto dcws	|zero sup. off
	lax dwch	|get a char
	prt
	ldx Temp
dcwlx,	tix dcwlp
	ldx doutad
	lax 5	|last number
	axr
	lax dwch	|last char
	prt
dcwrx,	tra .

dwch,	text .000111222333444555666777888999.

variables
constants
|p 8
|mag tape to pdp-1

buflng=1000.


begin,	write 6
tx0-pdp for calcomp
version of 4-3-70 (M. Ewing)
9

	write 6
tac 17:
	up- start at record no.=TSS 0
	    stop after record no.=TSS 1

9
	write 6
	down- process all of current tape file
9
	carrig
	write 6tac 1:	up to print tape record no.9
	write 6
	(remember CM SELECT -- OFF)
9

	write 6
load tape and restart
9

	hlt
	rew 1
restart,
norew,	tac
	cyr
	trn .+2
	tra dwn17
	lda 0
	add (-2
	tze nskp
	trn nskp
	axr
	rtb 1	|skip to first record
	tix .-1
nskp,	lda 0
	add (-1
	sto Mcnt	|set mcnt to first record to be run
	tra go

dwn17,	stz Mcnt
go,
rdloop,	tsx read
	buf
rcnt,	500.	|expected record length
	tra finish	|on error indication

	tac
	cyr
	cyr
	trn .+2
	tra dwn1
	carrig
	write 6tape record no.= 9
	opt mcnt
	write 6 octal,  9
	dpt mcnt
	write 6 decimal9
	carrig

dwn1,
	stz Jrcnt
	ldx (buf
	sxa shll
shll,	lda .
	tsx shufl
	slr Temp
	llr (77
	ldx (2
xloop,	lda Temp
	repeat 6, disUcyl	
		|display some stuff
	sto temp
	ana	|mask out all but 6 bits
	ial
	ex7	|set link ff
	nop	|slow up
	tlv .	|wait for ok from pdp
		|note: tlv xfer on ff set
	ial	|restore 77 to lr, code to ac
	add (-23	|test for new pict code
	tze skipr	|rest of rec no good if so
	tix xloop
	ado shll
	ado jrcnt
	com
	add rcnt
	trn .+2
	tra shll
skipr,	ado mcnt
	tac	|check tac 17
	cyr
	trn .+2
	tra rdloop
	lda mcnt
	com
	add 1	|TSS 1 is limit
	trn finish	|if limit reached
	tra rdloop

finish,	llr (400000	|end of file flag
	ex7	|set ff
	nop	|slow up
	tlv .	|wait
	nop
	write 6
eof to pdp-1
9
	opt mcnt
	write 6 octal,  9
	dpt mcnt
	write 6 decimal9
	write 6  records transferred.

tac0 up - continue, down restart
9
	hlt
	tac
	trn restart
	rew 1
	tra begin
variables
constants

dimension buf(buflng)

variables
start begin
m