Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-02 - decus/20-0027/pdp8.mac
There are 3 other files named pdp8.mac in the archive. Click here to see a list.
00100	TITLE	PDP8 SIMULATOR	VERSION #2	SEPT. 1 '69
00200	SUBTTL	DAVE MCCLURE'S MODIFICATIONS TO DON WITCRAFT'S ORIGINAL
00300	
00400	
00500	;CONSOLE INQUIRY
00600	
00700	ENTRY CYCLE,TC,NXIOT
00800	EXTERNAL CONSOLE,ERROR,NTIME,TIME,SR
00900	
01000		JOBVER=137
01100		VERNUM=2
01200		LOC	JOBVER
01300		VERNUM
01400		RELOC
01500	
01600	
01700	
01800	TC0:	HRLOI	AC1,377777	;SET NO TIME OUT
01900		MOVEM	AC1,NTIME
02000		MOVSI	AC1,MDLISTL	;SEARCH FOR ACTIVE DEVICES
02100	TC1:	MOVE	DDB,DLIST(AC1)	;LOAD ADDRES OF DEVICE DATA BLOCK
02200		MOVS	AC2,DFLAG(DDB)	;[XWD DEVICE FLAG FOR PDP8,,ACTIVE FLAG]
02300		TLNN	FLAGS,(AC2)	;DEVICE ACTIVE?
02400	TC2:	AOBJN	AC1,TC1		;NO
02500		JUMPGE	AC1,TC3		;JUMP IF DONE.
02600		CAMGE	RUNTIM,DTIME(DDB)	;DEVICE NEED ATTENTION?
02700		JRST	TC4		;NO
02800		TLZ	FLAGS,(AC2)	;YES. DEACTIVATE DEVICE
02900		MOVS	AC0,AC2		;[XWD  ACTIVE FLAG,,DEVICE FLAG FOR PDP8]
03000		TRO	FLAGS,(AC0)	;TURN ON DEVICE FLAG
03100		MOVE	AC0,DRATE(DDB)	;LOAD INTERRUPT DELAY TIME CONSTANT
03200		ADDB	AC0,DTIME(DDB)	;ADD LAST FLAG TIME
03300		SKIPE	AC3,DDISP(DDB)	;LOAD DISPATCH ADDRESS
03400		TLZN	AC3,400000	;SET DELAY TIME IMMEDIATELY?
03500		JRST	TC2A
03600		TLO	FLAGS,(AC2)	;SET DEVICE ACTIVE AGAIN
03700		CAMGE	AC0,NTIME	;NEXT DEVICE TO FLAG?
03800		MOVEM	AC0,NTIME	;YES
03900	TC2A:	JUMPE	AC3,TC2		;DISPATCH TO A SPECIAL ROUTINE?
04000		PUSHJ	PDP,(AC3)	;SO GO
04100		JRST	TC2		;NEXT DEVICE
04200	TC4:	MOVE	AC2,DTIME(DDB)	;LOAD TIME FOR NEXT INTERRUPT
04300		CAMGE	AC2,NTIME	;NEXT DEVICE TO NEED ATTENTION?
04400		MOVEM	AC2,NTIME	;YES
04500		JRST	TC2
04600	
04700	
04800	CYCLE:	TLNN	FLAGS,RUN	;IS MACHINE HALTED?
04900		PUSHJ	PDP,CONSOLE	;YES
05000	
05100	;TIME CONTROL
05200	TC:	ADDB	RUNTIM,TIME	;ACCUMULATE LAST INSTRUCTION TIME
05300		CAML	RUNTIME,NTIME	;TIME TO RAISE A FLAG
05400		JRST	TC0		;YES
05500	TC3:	SETZM	RUNTIME		;CLEAR TIME FOR THIS INSTRUCTION
05600		IFE DRM08,<TRZE	FLAGS,BRQFLG	;BREAK REQUEST?
05700		PUSHJ	PDP,BREAK	;YES.>
05800	
05900	
06000	;INTERRUPT SIMULATION
06100	
06200	EXTERNAL IBR,DFF,IF,DFSAVE,IFSAVE
06300	
06400		TLZE	FLAGS,INTDEL	;INTERRUPT DELAY?
06500		JRST	INSFET		;YES. TURN IT OFF AND CONTINUE.
06600		TRNE	FLAGS,INTFLG	;NO. IS THERE A PI REQUEST?
06700		TRNN	FLAGS,PION	;YES, IS PI TURNED ON?
06800		JRST	INSFET		;NO.
06900		TRZ	FLAGS,PION	;YES. DISABLE INTERRUPT.
07000		SETZB	AC0,IBR		;SAVE AND CLEAR IF AND DFF.
07100		EXCH	AC0,DFF
07200		MOVEM	AC0,DFSAVE
07300		MOVE	AC0,IF
07400		MOVEM	AC0,IFSAVE
07500		SETZM	MA
07600		JRST	JMS		;JMS 0 AND START A NEW INSTRUCTION CYCLE
     
00100	;INSTRUCTION FETCH
00200	
00300	INTERNAL FETOP1
00400	
00500	INSFET:	IFE ESTOP,<TRZE	PC,770000	;PC POLUTED
00600		ENTRY	INSFET
00700		PUSHJ	PDP,ERROR	;YES>
00800		IFN ESTOP,<TRZ	PC,770000	;MAKE SURE IT WASN'T>
00900		MOVE	MA,PC
01000		IFETCH
01100		MOVE	IR,MB		;LOAD INSTRUCTION IN THE IR
01200		LSH	IR,-^D9		;LEAVE ONLY THE OP CODE
01300		IFN PDP8S<ADDI	RUNTIM,6>
01400		IFE PDP8S<ADDI	RUNTIM,^D72>
01500		CAIL	IR,6		;ONE-CYCLE INSTRUCTION?
01600		JRST	DISP		;YES.  EXECUTE
01700	
01800	;COMPUTE EFFECTIVE ADDRESS IN MA
01900	
02000		MOVE	MA,MB
02100		ANDI	MA,177
02200		TRNN	MB,200		;PAGE 0
02300		JRST	.+4		;YES
02400		MOVE	AC0,PC
02500		ANDI	AC0,7600
02600		ORI	MA,(AC0)	;ADD CURRENT PAGE
02700	
02800		TRNN	MB,400		;INDIRECT?
02900		JRST	DISP		;NO
03000		IFN PDP8S<ADDI	RUNTIM,6>
03100		IFE PDP8S<ADDI	RUNTIM,^D72>
03200		IFETCH
03300		CAIG	MA,17		;AUTO INDEXING?
03400		CAIGE	MA,10
03500		JRST	FETOP0		;NO
03600		IFE FAST,<AOS	MB,CORE(AC1)	;YES, INCREMENT EFFECTIVE ADDRESS
03700		TRZE	MB,770000	;OVERFLOW OUT OF 12 BITS?
03800		SETZM	CORE(AC1)	;YES SO BE SURE MEMORY IS 0>
03900		IFN FAST,<AOS	MB	;YES, INCREMENT EFFECTIVE ADDRESS
04000		ISTORE>
04100	FETOP0:	CAIG	IR,3		;FOR JMP AND JMS DON'T
04200		TLO	FLAGS,DEFER	;SET "USE DATA FIELD" FLAG
04300	FETOP1:	MOVE	MA,MB
04400	
04500	
04600	;EXECUTE INSTRUCTION
04700	
04800	DISP:	AOS	PC
04900		XCT	OPCODE(IR)
05000		JRST	CYCLE
05100	;INSTRUCTION DISPATCH TABLE
05200	
05300	OPCODE:	JRST	AND
05400		JRST	TAD
05500		JRST	ISZ
05600		JRST	DCA
05700		JRST	JMS
05800		JRST	JMP
05900		PUSHJ	PDP,IOT
06000		PUSHJ	PDP,OPERATE
     
00100	INTERNAL FETCHY,STOREY
00200	
00300	IFE INLINE,<
00400	IFE PACK,<INTERNAL FETPNT
00500		EXTERNAL	CORE
00600	FETPNT:	POINT 12,CORE(AC1),11
00700		POINT 12,CORE(AC1),23
00800		POINT 12,CORE(AC1),35>
00900	IFN PACK,<EXTERNAL CORE>
01000	FETCHY:	FETCH
01100		POPJ	PDP,
01200	STOREY:	STORE
01300		POPJ	PDP,
01400	>
01500	
01600	IFN INLINE,<
01700	
01800	FETCHY:	PUSHJ	PDP,ADRCAL
01900	IFE PACK,<LDB	MB,FETPNT(AC2)>
02000	IFN PACK,<MOVE MB,CORE(AC1)>
02100		POPJ	PDP,
02200	
02300	STOREY:	PUSHJ	PDP,ADRCAL
02400	IFE PACK,<DPB	MB,FETPNT(AC2)>
02500	IFN PACK,<MOVEM MB,CORE(AC1)>
02600		POPJ	PDP,
02700	
02800	
02900	,CALCULATE PDP10 ADDRESS POINTER FROM MA.
03000	,RETURN WITH AC1=QUOTIENT(MA/3)
03100	,	AC2=REMAINTER(MA/3)
03200	
03300	
03400	ADRCAL:	ANDI	MA,7777
03500		MOVE	AC1,MA
03600		MOVE	AC0,IF
03700		TLZE	FLAGS,DEFER	;INDIRECT?
03800		MOVE	AC0,DFF		;YES. USE DATA FIELD.
03900		OR	AC1,AC0
04000	IFE PACK,<IDIVI	AC1,3
04100		POPJ	PDP,>
04200	>
     
00100	AND:	IFE PDP8S,<ADDI RUNTIM,^D72>
00200		IFN PDP8S,<ADDI RUNTIM,6>
00300		FETCH
00400		ANDI	AC,10000(MB)
00500		JRST	CYCLE
00600	
00700	TAD:	IFE PDP8S,<ADDI RUNTIME,^D18>
00800		IFN PDP8S,<ADDI RUNTIME,6>
00900		FETCH
01000		ADD	AC,MB
01100		ANDI	AC,17777	;DELETE CARRYOUTS
01200		JRST	CYCLE
01300	
01400	ISZ:	IFE PDP8S,<ADDI	RUNTIM,^D144>
01500		IFN PDP8S,<ADDI RUNTIME,6>
01600	
01700		IFE FAST,<
01800		MOVE	AC1,MA
01900		TLNE	FLAGS,DEFER
02000		OR	AC1,DFF		;YES SO USE DATA FIELD
02100		TLZN	FLAGS,DEFER	;USE INSTRUCTION FIELD?
02200		OR	AC1,IF		;YES
02300		AOS	AC0,CORE(AC1)	;INCREMENT CORE LOCATION
02400		TRNN	AC0,10000	;DID WE GO TO ZERO?
02500		JRST	CYCLE		;NO SO INSTRUCTION COMPLETE
02600		SETZM	CORE(AC1)	;YES SO SET LOCATION TO ZERO
02700		AOJA	PC,CYCLE	;SKIP PC AND END INSTRUCTION>
02800	
02900		IFN FAST,<MOVEM	FLAGS,AC0	;SAVE DEFER IF ON
03000		FETCH
03100		AOS	MB
03200		TRNN	MB,7777
03300		AOS	PC		;IF Y=0,PC:=PC+1
03400		MOVE	FLAGS,AC0	;RESTORE DEFER
03500		STORE
03600		JRST	CYCLE>
03700	
03800	DCA:	IFE PDP8S,<ADDI	RUNTIM,112>
03900		IFN PDP8S,<ADDI RUNTIME,6>
04000		MOVE	MB,AC
04100	IFN PACK,<ANDI	MB,7777		;REMOVE LINK IF PRESENT>
04200		ANDI	AC,10000	;LEAVE ONLY LINK BIT
04300		STORE
04400		JRST	CYCLE
04500	
04600	JMS:	IFN PDP8S,<ADDI RUNTIME,6>
04700		IFE PDP8S,<ADDI	RUNTIM,112>
04800		MOVE	AC0,IBR
04900		MOVEM	AC0,IF
05000	
05100		IFE FAST,<
05200		MOVE	AC1,MA
05300		OR	AC1,IF
05400		MOVEM	PC,CORE(AC1)	;SAVE PC
05500		MOVE	PC,MA
05600		AOJA	PC,CYCLE>
05700	
05800		IFN FAST,<MOVE	MB,PC
05900		MOVE	PC,MA
06000		STORE
06100		AOJA	PC,CYCLE>
06200	
06300	JMP:	IFE PDP8S,<ADDI	RUNTIM,40>
06400		MOVE	AC0,IBR
06500		MOVEM	AC0,IF
06600		MOVE	PC,MA
06700		JRST	CYCLE
     
00100	OPERAT:	TRNE	MB,400
00200		JRST	OPR2
00300	OPR1:	IFE PDP8S,<ADDI	RUNTIM,40>
00400		TRNE	MB,200
00500		ANDI	AC,10000		;CLA
00600		TRNE	MB,100
00700		ANDI	AC,7777		;CLL
00800		TRNE	MB,40
00900		XORI	AC,7777		;CMA
01000		TRNE	MB,20
01100		XORI	AC,10000	;CML
01200		IFN PDP8,<TRNE	MB,1	;FOR THE 8I,8L,8S IAC IS TIME 3
01300		PUSHJ	PDP,IAC>
01400		TRNE	MB,10
01500		JRST	ROT		;ROTATE AC AND L RIGHT
01600		TRNE	MB,4
01700		JRST	ROTL		;ROTATE AC AND L LEFT
01800		IFE PDP8,<		;FOR A PDP8 IAC ONLY IF NO ROTATE
01900		TRNE	MB,1
02000		JRST	IAC>
02100		POPJ	PDP,
02200	IAC:	ADDI	AC,1		;INCREMENT IAC
02300		ANDI	AC,17777	;REMOVE OVERFLOW IF PRESENT
02400		POPJ	PDP,
02500	;ROTATE AC AND L RIGHT
02600	
02700	INTERNAL EAE,OPR2
02800	
02900	ROT:	TRNE	MB,4		;IS BIT ON FOR LEFT ROTATION?
03000		JRST	DOUBLE		;YES
03100	ROTR:	ROT	AC,-1
03200		TLZE	AC,400000
03300		IORI	AC,10000
03400		TRZE	MB,2
03500		JRST	ROTR
03600		POPJ	PDP,
03700	
03800	;ROTATE AC AND L LEFT
03900	
04000	ROTL:	ROT	AC,1
04100		TRZE	AC,20000
04200		IORI	AC,1
04300		TRZE	MB,2
04400		JRST	ROTL
04500		POPJ	PDP,
04600	
04700	DOUBLE:	MOVEM	MB,AC0		;SAVE BIT FOR ROTATE TWICE
04800		MOVEM	AC,AC1		;SAVE ORIGINAL AC
04900		MOVEM	AC,AC2
05000		PUSHJ	PDP,ROTR
05100		EXCH	AC,AC2		;SAVE RIGHT ROTATED AC
05200		MOVE	MB,AC0		;RESTORE INSTRUCTION
05300		PUSHJ	PDP,ROTL
05400		MOVEM	AC,AC3		;SAVE LEFT ROTATED VERSION
05500		IFE PDP8,<AND	AC,AC1
05600		AND	AC1,AC2
05700		AND	AC2,AC3
05800		OR	AC,AC1
05900		OR	AC,AC2		;BUT WAS THIS WORTH THE TROUBLE?>
06000		IFN PDP8,<AND	AC,AC2	;FOR PDP8I>
06100		IFE ESTOP,<PUSHJ PDP,ERROR>
06200		IFN ESTOP,<POPJ PDP,>
06300	
06400	OPR2:	IFE PDP8S,<ADDI RUNTIM,80>
06500		TRNE	MB,1		;EAE INSTRUCTION?
06600		JRST	EAE		;YES
06700		SETZM	AC0
06800		TRNE	AC,10000
06900		TRO	AC0,20	;L=1
07000		TRNN	AC,7777
07100		TRO	AC0,40	;AC=0
07200		TRNE	AC,4000
07300		TRO	AC0,100	;AC<0
07400		AND	AC0,MB
07500		TRNE	MB,10		;REVERSE SKIP SENSE?
07600		JRST	OPRRSS		;YES
07700		TRNE	AC0,160		;SKIP IF ANY SELECTED CONDITION MET.
07800		AOJA	PC,.+4
07900		JRST	.+3
08000	OPRRSS:	TRNN	AC0,160
08100		AOS	PC
08200		TRNE	MB,200
08300		TRZ	AC,7777	;CLA
08400		TRNE	MB,4	;EVENT TIME 2
08500		OR	AC,SR
08600		TRNE	MB,2
08700	HALT:	TLZ	FLAGS,RUN
08800		POPJ	PDP,
08900	
09000	EAE:	IFE ESTOP,<PUSHJ	PDP,ERROR>
09100		IFN ESTOP,<POPJ	PDP,	;EAE INSTRUCTIONS GO HERE WHEN IMPLEMENTED>
     
00100	IOT:	IFE PDP8,<ADDI	RUNTIME,9>
00200		IFE PDP8I,<ADDI	RUNTIM,10>
00300		IFE PDP8L,<ADDI	RUNTIM,11>
00400		IFE PDP8S,<ADDI RUNTIM,80>
00500	IFN INLINE,<LDB	AC0,[POINT 9,MB,35]	;LOAD LEAST SIGNIFICANT 9BITS OF IOT
00600		LSH	AC0,5
00700		MOVSI	AC1,-IOTN
00800		HLRZ	AC2,IOTIT(AC1)
00900		CAMN	AC0,AC2
01000		JRST	@IOTIT(AC1)
01100		AOBJN	AC1,.-3>
01200	IFE INLINE,<JRST @IOTIT-6000(MB)>
01300	NXIOT:	IFE ESTOP,<PUSHJ	PDP,ERROR>
01400		IFN ESTOP,<POPJ	PDP,>
01500	
01600	
01700	DEFINE	IOTS
01800	<	X 1,ION
01900		X 2,IOF
02000		X 11,RSF
02100		X 12,RRB
02200		X 14,RFC
02300		X 16,RRBRFC
02400		X 21,PSF
02500		X 22,PCF
02600		X 24,PPC
02700		X 26,PLS
02800		X 31,KSF
02900		X 32,KCC
03000		X 34,KRS
03100		X 36,KRB
03200		X 41,TSF
03300		X 42,TCF
03400		X 44,TPC
03500		X 46,TLS
03600		X 101,SMP
03700		X 102,SPL
03800		X 104,CMP
03900		X 201,CDF
04000		X 202,CIF
04100		IFG <MEMSIZ-10000>,<X 211,CDF
04200		X 212,CIF>
04300		X 214,RDF
04400		IFG <MEMSIZ-20000>,<X 221,CDF
04500		X 222,CIF>
04600		X 224,RIF
04700		IFG <MEMSIZ-30000>,<X 231,CDF
04800		X 232,CIF>
04900		X 234,RIB
05000		IFG <MEMSIZ-40000>,<X 241,CDF
05100		X 242,CIF>
05200		X 244,RMF
05300		IFG <MEMSIZ-50000>,<X 251,CDF
05400		X 252,CIF>
05500		IFG <MEMSIZ-60000>,<X 261,CDF
05600		X 262,CIF>
05700		IFG <MEMSIZ-70000>,<X 271,CDF
05800		X 272,CIF>
05900	IFE DCS680,<	X 401,TTINCR	;680 INSTRUCTIONS
06000		X 402,TTI
06100		X 403,TTI1
06200		X 404,TTO
06300		X 405,TTO1
06400		X 410,TT
06500		X 411,TTCL
06600		X 412,TTSL
06700		X 413,TTSLC
06800		X 414,TTRL
06900		X 421,T5SKP
07000		X 422,TT5OFF
07100		X 424,TT5ON
07200		X 431,T8SKP
07300		X 432,TT8OFF
07400		X 434,TT8ON>
07500	IFE PLOTER,<X 501,PLSF
07600		X 502,PLCF
07700		X 504,PLPU
07800		X 511,PLPR
07900		X 512,PLDU
08000		X 513,PLPRDU
08100		X 514,PLDD
08200		X 515,PLPRDD
08300		X 521,PLPL
08400		X 522,PLUD
08500		X 523,PLPLUD
08600		X 524,PLPD>
08700	IFN DDF32,<X 601,DCMA	;DISK TYPE DF32
08800		X 603,DMAR
08900		X 605,DMAW
09000		X 611,DCEA
09100		X 612,DSAC
09200		X 615,DEAL
09300		X 616,DEAC
09400		X 621,DFSE
09500		X 622,DFSC
09600		X 626,DMAC>
09700	IFE DRM08,<X 603,DRCR	;DRUM TYPE RM08
09800		X 605,DRCW
09900		X 611,DRCF
10000		X 612,DREF
10100		X 615,DRTS
10200		X 621,DRSE
10300		X 622,DRSC
10400		X 624,DRCN>
10500		X 777,NXIOT
10600	>
     
00100	IFN INLINE,<DEFINE X (A,C)
00200	<	XWD A*40,C
00300	IFDIF <C><ION>,<IFDIF <C><IOF>,<IFDIF <C><NXIOT>,<EXTERNAL C>>>>>
00400	
00500	IFE INLINE,<SIZE=0
00600	DEFINE X(A,C)<
00700		SIZE=A-SIZE
00800		REPEAT SIZE,<NXIOT>
00900		SIZE=A+1
01000		EXP	C
01100		IFDIF <C><ION>,<IFDIF <C><IOF>,<IFDIF <C><NXIOT>,<EXTERNAL C>>>>>
01200	
01300	
01400	IOTIT:	IOTS
01500	IOTN=.-IOTIT
     
00100	ION:	TRON	FLAGS,PION		;IS PI TURNED ON? TURN IT ON.
00200		TLO	FLAGS,INTDEL	;NO. DELAY INTERRUPT ENABLE.
00300		POPJ	PDP,
00400	
00500	IOF:	TRZ	FLAGS,PION		;INTERRUPT TURN OFF.
00600		TLZ	FLAGS,INTDEL
00700		POPJ	PDP,
00800	
00900	
01000	;DATA BREAK SIMULATOR
01100	IFE DRM08,<
01200	EXTERNAL DCL,DFB
01300	
01400	BREAK:	ADDI	RUNTIM,6	;ONE MEMORY CYCLE.
01500		MOVE	MA,DCL		;CORE ADDRESS
01600		TRNN	FLAGS,DRWC	;WRITING?
01700		JRST	BREAKR		;NO
01800		FETCH			;YES. GET WORD FROM CORE.
01900		MOVEM	MB,DFB
02000		TLO	FLAGS,DFBCHG	;SET DFB CHANGE FLAG.
02100		POPJ	PDP,
02200	
02300	BREAKR:	MOVE	MB,DFB		;READING.
02400		STORE			;STORE WORD IN CORE.
02500		TLZ	FLAGS,DFBCHG	;CLEAR DFB CHANGE FLAG.
02600		AOS	DCL
02700		POPJ	PDP,>
     
00100	;DEVICE LIST	...	DEVICE DATA BLOCK ADDRESSES
00200	
00300	DEFINE DV(X)
00400	<	EXP X'DATA
00500	EXTERNAL X'DATA>
00600	
00700	DLIST:	DV R
00800		DV P
00900		DV T
01000		DV K
01100	IFE PLOTER,<DV PL>
01200	IFN DDF32,<DV D>
01300	IFE DRM08,<DV DM>
01400	IFE DCS680,<DV C8
01500		DV C5
01600		DV L0
01700		DV L1>
01800		DV DR
01900	MDLIST=DLIST-.
02000	
02100	INTERNAL MDLISTL,DLIST
02200	
02300	DEFINE CV(X)
02400	<	EXP X'CDATA
02500	EXTERNAL X'CDATA>
02600	
02700	;CHANNEL LIST	...	FILE DATA BLOCK ADDRESSES
02800	
02900	CLIST:	CV R
03000		CV P
03100	IFE PLOTER,<CV PL>
03200	IFN DDF32,<CV D>
03300	IFE DRM08,<CV DI
03400		CV DO>
03500	IFE DCS680,<CV LI0
03600		CV LO0
03700		CV LI1
03800		CV LO1
03900		CV PT
04000		CV DT>
04100	
04200	CLISTL=.-CLIST
04300	MCLIST=-CLISTL
04400	
04500	INTERNAL CLISTL,MCLIST,CLIST
04600	
04700		END