Google
 

Trailing-Edge - PDP-10 Archives - BB-F493Z-DD_1986 - 10,7/8cards.mac
There are 5 other files named 8cards.mac in the archive. Click here to see a list.
TITLE 8CARDS - PUNCH PDP-8 CARD DECK FROM PAL10 .BIN FILES

; AC'S

F==0
A==1
B==A+1
C==B+1
D==4
E==5
F==6
T==10
T1==T+1
T2==T1+1
X==16
P==17

; IO CHANNELS

INC==1
OUTC==2

LPD==40		; LENGTH OF PUSH DOWN LIST

DEFINE	TELL(A)	<
			OUTSTR [ASCIZ \A
\]>

DEFINE	FAIL(A)<
		JRST [TELL <A>
				EXIT]>

; PDP-8 INSTRUCTIONS

CDF=6201
CIF=6202

ST:	RESET
	MOVE P,[-LPD,,PDL-1]
	OPEN INC,OPNIN
	FAIL <CAN'T INIT DSK FOR INPUT>
	LOOKUP INC,LDFIL		; GET LOADER FIRST
	FAIL <IN INPUT FILE DSK:CLDR.BIN>
	SETZB A,LDFIL+2
	HRRM A,LDFIL+1
	SETZM LDFIL+3
	OPEN OUTC,OPNOUT
	FAIL <CAN'T INIT CDP>
	ENTER OUTC,OUTFIL
	FAIL <CAN'T ENTER FILE CARDS.CDP>
	SETZB A,OUTFIL+2
	HRRM A,OUTFIL+1
	SETZM A,OUTFIL+3
	PUSHJ P,OUTOUT			; DAMNED SPOT !
	MOVE A,[SIXBIT /PDP8 0/]
	MOVEM A,IDENT
	MOVE A,[SIXBIT /00    /]
	MOVEM A,IDENT+1

; NOW PUT OUT THE LOADER ONTO THE FIRST CARD

	MOVSI A,-^D80+LID-1
STLP:	PUSHJ P,LGETCH			; FLUSH LEADER OFF LOADER
	TRNE T,200			; IS LEADER ?
	JRST STLP			; YES, FORGET IT
	TRNN T,100			; IS ORG ?
	FAIL <CLDR.BIN FILE CONFUSING>	; NO, THIS SIMPLE PROGRAM DOESN'T UNDERSTAND
LDLP3:	PUSHJ P,LGETCH			; YES, IGNORE IT ALL

; NOW WE HAVE A LOADER READY, PUT IT ON THE FIRST CARD AS IS.

LDLP1:	PUSHJ P,LGETCH
	TRNE T,100			; IS ORG ?
	JRST LDLP3			; IGNORE ORGS
	TRNE T,200			; IS TRAILER ?
	JRST LDLP2			; YES, WE'RE DONE
	DPB T,[POINT 6,CD(A),29]
	PUSHJ P,LGETCH
	TRNE T,300			; ORG OR LEADER OR FIELD
	FAIL <CLDR.BIN FILE CONFUSED ! >
	DPB T,[POINT 6,CD(A),35]
	AOBJN A,LDLP1
	FAIL <LOADER DOESN'T FIT ON A CARD>

LDLP2:	SUB A,[1,,1]			; UNDO CHECKSUM
LDLP22:	SETZM CD(A)			; ZERO OUT REST OF CARD TO ID FIELD
	AOBJN A,LDLP22
	PUSHJ P,PNCHIT			; PUNCH THE LOADER

; GOT LOADER PUNCHED, NOW CONVERT THE FILE TO BE LOADED

	LOOKUP INC,INFIL		; GET THE .BIN FILE
	FAIL <CAN'T FIND FILE DSK:PCH.BIN>
	SETZM FLDS#			; START IN FIELD 0
	SETZM CADDR#			; AT LOCATION 0
	SETZM CCHKSM#			; START WITH 0 CHECKSUM
	MOVSI A,-MAXDAT			; WORDS PER CARD, LATER SET UP BY PNCHIT
PL1:	PUSHJ P,PGETCH			; GET A FRAME
	CAIE T,200			; WAIT FOR LEADER
	JRST PL1
PL2:	PUSHJ P,PGETCH			; GET ANOTHER FRAME
	CAIN T,200			; IS LEADER ?
	JRST PL2			; YES , IGNORE

; NOW WE HAVE READ DATA - OF SOME KIND

PL3:	LDB T1,[POINT 2,T,29]		; GET CHANNELS 7 AND 8 OFF BY THEMSELVES
	JRST @[DATA
		ORG
		TLR
		FIELD](T1)

DATA:	DPB T,[POINT 6,DAT(A),29]	; LEFT 6 BITS OF DATA
	PUSHJ P,PGZ			; GET DATA WITH 0 IN CH 7 & 8
	DPB T,[POINT 6,DAT(A),35]	; RIGHT 6 BITS OF DATA
	AOS CADDR#			; NEXT ADDRESS
	AOBJN A,NXTWD			; NEXT WORD ON CARD
NEWCD:	PUSHJ P,PUNCD			; END OF CARD, PUNCH IT IN LOADER FORMAT
NXTWD:	PUSHJ P,PGETCH			; GET NEXT CHAR
	JRST PL3			; AND TRY AGAIN

ORG:	SETZM B
	DPB T,[POINT 6,B,29]
	PUSHJ P,PGZ
	DPB T,[POINT 6,B,35]
	MOVEM B,CADDR#
	JRST NEWCD

FIELD:	LSH T,-3			; GET THE FIELD BITS
	TRZ T,777770			; AND NO OTHERS
	MOVEM T,FLDS#			; SAVE
	JRST NEWCD

; FOUND A TRAILER CODE, WE'RE OUT OF PROGRAM TO LOAD

TLR:	SUB A,[1,,1]			; UNDO CHECKSUM
	SOS CADDR#
	SETZM DAT(A)		; MORE UNDOING OF THAT
				; MISERABLE CHECKSUM THAT LOOKS LIKE DATA
	PUSHJ P,PUNCD			; FINISH OFF THE LAST CARD
	MOVEI T,CIF!CDF		; HAVE TO CHANGE INSTR FIELD ALSO
	IORM T,FLD
	PUSHJ P,PUNCD1		; PUNCH OUT START CARD TO CURRENT ADDR
	CLOSE INC,
	CLOSE OUTC,
	EXIT

; SUBROUTINES

PUNCD:	CAMG A,[-MAXDAT,,0]		; ANYTHING ON CARD ?
	JRST CLP4			; NO SET UP ADDR AND FIELD AND EXIT
PUNCD1:	HRRZ A,A			; SET WORD COUNT
	MOVNM A,WC
	MOVSI A,-3
	MOVE C,CCHKSM#
CLP2:	MOVE T1,CD(A)
	ANDI T1,7777
	ADD C,T1
	TRZE C,10000
	AOS C
	AOBJN A,CLP2
	MOVEM C,CCHKSM#
	MOVNM C,CD(A)
	HRLZ A,WC
	JUMPGE A,CLP5
	MOVE C,CCHKSM#
CLP1:	MOVE T1,DAT(A)
	ANDI T1,7777
	ADD C,T1
	TRZE C,10000
	AOS C
	AOBJN A,CLP1
	MOVEM C,CCHKSM#
	MOVNM C,DAT(A)
CLP5:	PUSHJ P,PNCHIT
CLP4:	MOVEI T1,CDF
	MOVEM T1,FLD
	MOVE T1,FLDS#
	DPB T1,[POINT 3,FLD,32]
	MOVE T1,CADDR#
	MOVEM T1,ADDR
	MOVSI A,-MAXDAT
	POPJ P,

PNCHIT:	MOVEI D,LID-1			; NO OF CH IN ID FIELD
IDLP:	MOVE T1,D
	IDIVI T1,6			; CH / WD
	LDB E,IDTBL(T2)			; PICK UP RIGHT BYTE
	MOVE F,E			; SAVE
	CAIN E,'9'			; WORRY ABOUT CARRYS
	MOVEI E,'0'
	CAIN E,'Z'
	MOVEI E,'A'
	CAIN E,(F)			; DID WE CARRY ?
	JRST NOCARY			; NO
	DPB E,IDTBL(T2)			; YES PUT BACK NEW CHARACTER
	SOJGE D,IDLP			; AND TRY NEXT CH
	JRST IDDN			; MOD SIZE OF ID FIELD

NOCARY:	AOS E				; ADD 1 TO ID
	DPB E,IDTBL(T2)			; AND SAVE IT
IDDN:	MOVSI D,-^D80+LID
PLP:	LDB T1,[POINT 12,CD(D),35]
	PUSHJ P,OUTWD
	AOBJN D,PLP
	HRLI D,-LID
	MOVE E,[POINT 6,IDENT]
PLP1:	ILDB T1,E
	IDIVI T1,3
	LDB T1,SXCT(T2)
	PUSHJ P,OUTWD
	AOBJN D,PLP1
	PUSHJ P,OUTOUT			; THATS ALL
	MOVSI A,-^D80
CLP3:	SETZM CD(A)
	AOBJN A,CLP3
	POPJ P,

OUTWD:	SOSGE OUTBF+2
	FAIL <CARD TOO SMALL>
	IDPB T1,OUTBF+1
	POPJ P,

OUTOUT:	OUT OUTC,
	JRST [	MOVE T1,OUTBF+2
		IMULI T1,3
		MOVEM T1,OUTBF+2
		MOVEI T1,001400
		HRLM T1,OUTBF+1
		POPJ P,
	     ]
	GETSTS OUTC,T1
	FAIL <OUTPUT ERROR>

GETCH:	SOSLE INBUFF+2
	JRST GETOK
	IN INC,
	JRST GETOK
	STATO INC,740000
	TELL <INPUT EOF BEFORE TRAILER>
	TELL <INPUT ERROR>
	POPJ P,

GETOK:	ILDB T,INBUFF+1
	AOS 0(P)
	POPJ P,

LGETCH:	PUSHJ P,GETCH
	FAIL <ON LOADER FILE>
	POPJ P,

PGETCH:	PUSHJ P,GETCH
	FAIL <ON PROGRAM FILE>
	POPJ P,

PGZ:	PUSHJ P,PGETCH
	TRNE T,300
	FAIL <FILE OUT OF SYNC>
	POPJ P,

; SIXBIT TO BINARY CARD ROW CONVERSION

; CARD CODES:

P9==1
P8==2
P7==4
P6==10
P5==20
P4==40
P3==100
P2==200
P1==400
P0==1000
P11==2000
P12==4000

; POINTER TO FOLLOWING TABLE

SXCT:	POINT 12,SXTOBN(T1),11
	POINT 12,SXTOBN(T1),23
	POINT 12,SXTOBN(T1),35

; ASCII TO 029 TABLE

SXTOBN:	BYTE (12)0,P11+P8+P2,P8+P7		; SPACE ! "
	BYTE (12)P8+P3,P11+P8+P3,P0+P8+P4	; # $ %
	BYTE (12)P12,P8+P5,P12+P8+P5		; & ' (
	BYTE (12)P11+P8+P5,P11+P8+P4,P12+P8+P6	; ) * +
	BYTE (12)P0+P8+P3,P11,P12+P8+P3		; , - .
	BYTE (12)P0+P1,P0,P1			; / 0 1
	BYTE (12)P2,P3,P4			; 2 3 4
	BYTE (12)P5,P6,P7			; 5 6 7
	BYTE (12)P8,P9,P8+P2			; 8 9 :
	BYTE (12)P11+P8+P6,P12+P8+P4,P8+P6	; ; < =
	BYTE (12)P0+P8+P6,P12+P8+P4,P8+P6	; > ? @
	BYTE (12)P12+P1,P12+P2,P12+P3		; A B C
	BYTE (12)P12+P4,P12+P5,P12+P6		; D E F
	BYTE (12)P12+P7,P12+P8,P12+P9		; G H I
	BYTE (12)P11+P1,P11+P2,P11+P3		; J K L
	BYTE (12)P11+P4,P11+P5,P11+P6		; M N O
	BYTE (12)P11+P7,P11+P8,P11+P9		; P Q R
	BYTE (12)P0+P2,P0+P3,P0+P4		; S T U
	BYTE (12)P0+P5,P0+P6,P0+P7		; V W X
	BYTE (12)P0+P8,P0+P9,P12+P8+P7		; Y Z [
	BYTE (12)P11+P8+P7,P0+P8+P2,P12+P8+P7	; \ ] ^
	BYTE (12)P0+P8+P5,,			; _

; BYTE POINTERS FOR IDENT

IDTBL:	POINT 6,IDENT(T1),5
	POINT 6,IDENT(T1),11
	POINT 6,IDENT(T1),17
	POINT 6,IDENT(T1),23
	POINT 6,IDENT(T1),29
	POINT 6,IDENT(T1),35

; CARD ID FIELD IN SIXBIT

IDENT:	BLOCK 2

; I O STUFF

OPNIN:	10
	SIXBIT /DSK/
	INBUFF

INBUFF:	BLOCK 3

LDFIL:	SIXBIT /CLDR/
	SIXBIT /BIN/
	0
	0

INFIL:	SIXBIT /PCH/
	SIXBIT /BIN/
	0
	0

OPNOUT:	10
	SIXBIT /CDP/
	XWD OUTBF,

OUTBF:	BLOCK 3

OUTFIL:	SIXBIT /CARDS/
	SIXBIT /CDP/
	0
	0

; SIMULATED CARD

LID==^D8			; LENGTH OF ID FIELD

CD:
WC:	0		; 2'S COMP OF DATA WORDS ON CARD.  0 IS START CARD

ADDR:	0		; ADDRESS OF FIRST DATUM ON CARD OR LOCATION TO START AT

FLD:	0		; PDP-8 INSTRUCTION TO SET PROPER FIELD.
			; CDF IF DATA, CDF!CIF IF START

PCSM:	0		; 2'S COMP OF 1'S COMP CHECKSUM OF ALL PRECEEDING
			; PARAMETERS AND DATA

MAXDAT=^D68-1

DAT:	BLOCK MAXDAT+1	; DATA WITH 2'S COMP OF 1'S COMP CHECKSUM OF ALL 
			; PRECEEDING DATA AND PARAMETERS AT END

IDFLD:	BLOCK LID	; IDENTIFICATION FIELD

PAT:	BLOCK 100

PDL:	BLOCK LPD

	END ST