Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50146/pdp8.mac
There are 3 other files named pdp8.mac in the archive. Click here to see a list.
TITLE	PDP8 SIMULATOR	VERSION #2	SEPT. 1 '69
SUBTTL	DAVE MCCLURE'S MODIFICATIONS TO DON WITCRAFT'S ORIGINAL


,CONSOLE INQUIRY

ENTRY CYCLE,TC,NXIOT
EXTERNAL CONSOLE,ERROR,NTIME,TIME,SR

	JOBVER=137
	VERNUM=2
	LOC	JOBVER
	VERNUM
	RELOC



TC0:	HRLOI	AC1,377777	;SET NO TIME OUT
	MOVEM	AC1,NTIME
	MOVSI	AC1,MDLISTL	;SEARCH FOR ACTIVE DEVICES
TC1:	MOVE	DDB,DLIST(AC1)	;LOAD ADDRES OF DEVICE DATA BLOCK
	MOVS	AC2,DFLAG(DDB)	;[XWD DEVICE FLAG FOR PDP8,,ACTIVE FLAG]
	TLNN	FLAGS,(AC2)	;DEVICE ACTIVE?
TC2:	AOBJN	AC1,TC1		;NO
	JUMPGE	AC1,TC3		;JUMP IF DONE.
	CAMGE	RUNTIM,DTIME(DDB)	;DEVICE NEED ATTENTION?
	JRST	TC4		;NO
	TLZ	FLAGS,(AC2)	;YES. DEACTIVATE DEVICE
	MOVS	AC0,AC2		;[XWD  ACTIVE FLAG,,DEVICE FLAG FOR PDP8]
	TRO	FLAGS,(AC0)	;TURN ON DEVICE FLAG
	MOVE	AC0,DRATE(DDB)	;LOAD INTERRUPT DELAY TIME CONSTANT
	ADDB	AC0,DTIME(DDB)	;ADD LAST FLAG TIME
	SKIPE	AC3,DDISP(DDB)	;LOAD DISPATCH ADDRESS
	TLZN	AC3,400000	;SET DELAY TIME IMMEDIATELY?
	JRST	TC2A
	TLO	FLAGS,(AC2)	;SET DEVICE ACTIVE AGAIN
	CAMGE	AC0,NTIME	;NEXT DEVICE TO FLAG?
	MOVEM	AC0,NTIME	;YES
TC2A:	JUMPE	AC3,TC2		;DISPATCH TO A SPECIAL ROUTINE?
	PUSHJ	PDP,(AC3)	;SO GO
	JRST	TC2		;NEXT DEVICE
TC4:	MOVE	AC2,DTIME(DDB)	;LOAD TIME FOR NEXT INTERRUPT
	CAMGE	AC2,NTIME	;NEXT DEVICE TO NEED ATTENTION?
	MOVEM	AC2,NTIME	;YES
	JRST	TC2


CYCLE:	TLNN	FLAGS,RUN	;IS MACHINE HALTED?
	PUSHJ	PDP,CONSOLE	;YES

;TIME CONTROL
TC:	ADDB	RUNTIM,TIME	;ACCUMULATE LAST INSTRUCTION TIME
	CAML	RUNTIME,NTIME	;TIME TO RAISE A FLAG
	JRST	TC0		;YES
TC3:	SETZM	RUNTIME		;CLEAR TIME FOR THIS INSTRUCTION
	IFE DRM08,<TRZE	FLAGS,BRQFLG	;BREAK REQUEST?
	PUSHJ	PDP,BREAK	;YES.>


;INTERRUPT SIMULATION

EXTERNAL IBR,DFF,IF,DFSAVE,IFSAVE

	TLZE	FLAGS,INTDEL	;INTERRUPT DELAY?
	JRST	INSFET		;YES. TURN IT OFF AND CONTINUE.
	TRNE	FLAGS,INTFLG	;NO. IS THERE A PI REQUEST?
	TRNN	FLAGS,PION	;YES, IS PI TURNED ON?
	JRST	INSFET		;NO.
	TRZ	FLAGS,PION	;YES. DISABLE INTERRUPT.
	SETZB	AC0,IBR		;SAVE AND CLEAR IF AND DFF.
	EXCH	AC0,DFF
	MOVEM	AC0,DFSAVE
	MOVE	AC0,IF
	MOVEM	AC0,IFSAVE
	SETZM	MA
	JRST	JMS		;JMS 0 AND START A NEW INSTRUCTION CYCLE
;INSTRUCTION FETCH

INTERNAL FETOP1

INSFET:	IFE ESTOP,<TRZE	PC,770000	;PC POLUTED
	ENTRY	INSFET
	PUSHJ	PDP,ERROR	;YES>
	IFN ESTOP,<TRZ	PC,770000	;MAKE SURE IT WASN'T>
	MOVE	MA,PC
	IFETCH
	MOVE	IR,MB		;LOAD INSTRUCTION IN THE IR
	LSH	IR,-^D9		;LEAVE ONLY THE OP CODE
	IFN PDP8S<ADDI	RUNTIM,6>
	IFE PDP8S<ADDI	RUNTIM,^D72>
	CAIL	IR,6		;ONE-CYCLE INSTRUCTION?
	JRST	DISP		;YES.  EXECUTE

;COMPUTE EFFECTIVE ADDRESS IN MA

	MOVE	MA,MB
	ANDI	MA,177
	TRNN	MB,200		;PAGE 0
	JRST	.+4		;YES
	MOVE	AC0,PC
	ANDI	AC0,7600
	ORI	MA,(AC0)	;ADD CURRENT PAGE

	TRNN	MB,400		;INDIRECT?
	JRST	DISP		;NO
	IFN PDP8S<ADDI	RUNTIM,6>
	IFE PDP8S<ADDI	RUNTIM,^D72>
	IFETCH
	CAIG	MA,17		;AUTO INDEXING?
	CAIGE	MA,10
	JRST	FETOP0		;NO
	IFE FAST,<AOS	MB,CORE(AC1)	;YES, INCREMENT EFFECTIVE ADDRESS
	TRZE	MB,770000	;OVERFLOW OUT OF 12 BITS?
	SETZM	CORE(AC1)	;YES SO BE SURE MEMORY IS 0>
	IFN FAST,<AOS	MB	;YES, INCREMENT EFFECTIVE ADDRESS
	ISTORE>
FETOP0:	CAIG	IR,3		;FOR JMP AND JMS DON'T
	TLO	FLAGS,DEFER	;SET "USE DATA FIELD" FLAG
FETOP1:	MOVE	MA,MB


;EXECUTE INSTRUCTION

DISP:	AOS	PC
	XCT	OPCODE(IR)
	JRST	CYCLE
;INSTRUCTION DISPATCH TABLE

OPCODE:	JRST	AND
	JRST	TAD
	JRST	ISZ
	JRST	DCA
	JRST	JMS
	JRST	JMP
	PUSHJ	PDP,IOT
	PUSHJ	PDP,OPERATE
INTERNAL FETCHY,STOREY

IFE INLINE,<
IFE PACK,<INTERNAL FETPNT
	EXTERNAL	CORE
FETPNT:	POINT 12,CORE(AC1),11
	POINT 12,CORE(AC1),23
	POINT 12,CORE(AC1),35>
IFN PACK,<EXTERNAL CORE>
FETCHY:	FETCH
	POPJ	PDP,
STOREY:	STORE
	POPJ	PDP,
>

IFN INLINE,<

FETCHY:	PUSHJ	PDP,ADRCAL
IFE PACK,<LDB	MB,FETPNT(AC2)>
IFN PACK,<MOVE MB,CORE(AC1)>
	POPJ	PDP,

STOREY:	PUSHJ	PDP,ADRCAL
IFE PACK,<DPB	MB,FETPNT(AC2)>
IFN PACK,<MOVEM MB,CORE(AC1)>
	POPJ	PDP,


,CALCULATE PDP10 ADDRESS POINTER FROM MA.
,RETURN WITH AC1=QUOTIENT(MA/3)
,	AC2=REMAINTER(MA/3)


ADRCAL:	ANDI	MA,7777
	MOVE	AC1,MA
	MOVE	AC0,IF
	TLZE	FLAGS,DEFER	;INDIRECT?
	MOVE	AC0,DFF		;YES. USE DATA FIELD.
	OR	AC1,AC0
IFE PACK,<IDIVI	AC1,3
	POPJ	PDP,>
>
AND:	IFE PDP8S,<ADDI RUNTIM,^D72>
	IFN PDP8S,<ADDI RUNTIM,6>
	FETCH
	ANDI	AC,10000(MB)
	JRST	CYCLE

TAD:	IFE PDP8S,<ADDI RUNTIME,^D18>
	IFN PDP8S,<ADDI RUNTIME,6>
	FETCH
	ADD	AC,MB
	ANDI	AC,17777	;DELETE CARRYOUTS
	JRST	CYCLE

ISZ:	IFE PDP8S,<ADDI	RUNTIM,^D144>
	IFN PDP8S,<ADDI RUNTIME,6>

	IFE FAST,<
	MOVE	AC1,MA
	TLNE	FLAGS,DEFER
	OR	AC1,DFF		;YES SO USE DATA FIELD
	TLZN	FLAGS,DEFER	;USE INSTRUCTION FIELD?
	OR	AC1,IF		;YES
	AOS	AC0,CORE(AC1)	;INCREMENT CORE LOCATION
	TRNN	AC0,10000	;DID WE GO TO ZERO?
	JRST	CYCLE		;NO SO INSTRUCTION COMPLETE
	SETZM	CORE(AC1)	;YES SO SET LOCATION TO ZERO
	AOJA	PC,CYCLE	;SKIP PC AND END INSTRUCTION>

	IFN FAST,<MOVEM	FLAGS,AC0	;SAVE DEFER IF ON
	FETCH
	AOS	MB
	TRNN	MB,7777
	AOS	PC		;IF Y=0,PC:=PC+1
	MOVE	FLAGS,AC0	;RESTORE DEFER
	STORE
	JRST	CYCLE>

DCA:	IFE PDP8S,<ADDI	RUNTIM,112>
	IFN PDP8S,<ADDI RUNTIME,6>
	MOVE	MB,AC
IFN PACK,<ANDI	MB,7777		;REMOVE LINK IF PRESENT>
	ANDI	AC,10000	;LEAVE ONLY LINK BIT
	STORE
	JRST	CYCLE

JMS:	IFN PDP8S,<ADDI RUNTIME,6>
	IFE PDP8S,<ADDI	RUNTIM,112>
	MOVE	AC0,IBR
	MOVEM	AC0,IF

	IFE FAST,<
	MOVE	AC1,MA
	OR	AC1,IF
	MOVEM	PC,CORE(AC1)	;SAVE PC
	MOVE	PC,MA
	AOJA	PC,CYCLE>

	IFN FAST,<MOVE	MB,PC
	MOVE	PC,MA
	STORE
	AOJA	PC,CYCLE>

JMP:	IFE PDP8S,<ADDI	RUNTIM,40>
	MOVE	AC0,IBR
	MOVEM	AC0,IF
	MOVE	PC,MA
	JRST	CYCLE
OPERAT:	TRNE	MB,400
	JRST	OPR2
OPR1:	IFE PDP8S,<ADDI	RUNTIM,40>
	TRNE	MB,200
	ANDI	AC,10000		;CLA
	TRNE	MB,100
	ANDI	AC,7777		;CLL
	TRNE	MB,40
	XORI	AC,7777		;CMA
	TRNE	MB,20
	XORI	AC,10000	;CML
	IFN PDP8,<TRNE	MB,1	;FOR THE 8I,8L,8S IAC IS TIME 3
	PUSHJ	PDP,IAC>
	TRNE	MB,10
	JRST	ROT		;ROTATE AC AND L RIGHT
	TRNE	MB,4
	JRST	ROTL		;ROTATE AC AND L LEFT
	IFE PDP8,<		;FOR A PDP8 IAC ONLY IF NO ROTATE
	TRNE	MB,1
	JRST	IAC>
	POPJ	PDP,
IAC:	ADDI	AC,1		;INCREMENT IAC
	ANDI	AC,17777	;REMOVE OVERFLOW IF PRESENT
	POPJ	PDP,
;ROTATE AC AND L RIGHT

INTERNAL EAE,OPR2

ROT:	TRNE	MB,4		;IS BIT ON FOR LEFT ROTATION?
	JRST	DOUBLE		;YES
ROTR:	ROT	AC,-1
	TLZE	AC,400000
	IORI	AC,10000
	TRZE	MB,2
	JRST	ROTR
	POPJ	PDP,

;ROTATE AC AND L LEFT

ROTL:	ROT	AC,1
	TRZE	AC,20000
	IORI	AC,1
	TRZE	MB,2
	JRST	ROTL
	POPJ	PDP,

DOUBLE:	MOVEM	MB,AC0		;SAVE BIT FOR ROTATE TWICE
	MOVEM	AC,AC1		;SAVE ORIGINAL AC
	MOVEM	AC,AC2
	PUSHJ	PDP,ROTR
	EXCH	AC,AC2		;SAVE RIGHT ROTATED AC
	MOVE	MB,AC0		;RESTORE INSTRUCTION
	PUSHJ	PDP,ROTL
	MOVEM	AC,AC3		;SAVE LEFT ROTATED VERSION
	IFE PDP8,<AND	AC,AC1
	AND	AC1,AC2
	AND	AC2,AC3
	OR	AC,AC1
	OR	AC,AC2		;BUT WAS THIS WORTH THE TROUBLE?>
	IFN PDP8,<AND	AC,AC2	;FOR PDP8I>
	IFE ESTOP,<PUSHJ PDP,ERROR>
	IFN ESTOP,<POPJ PDP,>

OPR2:	IFE PDP8S,<ADDI RUNTIM,80>
	TRNE	MB,1		;EAE INSTRUCTION?
	JRST	EAE		;YES
	SETZM	AC0
	TRNE	AC,10000
	TRO	AC0,20	;L=1
	TRNN	AC,7777
	TRO	AC0,40	;AC=0
	TRNE	AC,4000
	TRO	AC0,100	;AC<0
	AND	AC0,MB
	TRNE	MB,10		;REVERSE SKIP SENSE?
	JRST	OPRRSS		;YES
	TRNE	AC0,160		;SKIP IF ANY SELECTED CONDITION MET.
	AOJA	PC,.+4
	JRST	.+3
OPRRSS:	TRNN	AC0,160
	AOS	PC
	TRNE	MB,200
	TRZ	AC,7777	;CLA
	TRNE	MB,4	;EVENT TIME 2
	OR	AC,SR
	TRNE	MB,2
HALT:	TLZ	FLAGS,RUN
	POPJ	PDP,

EAE:	IFE ESTOP,<PUSHJ	PDP,ERROR>
	IFN ESTOP,<POPJ	PDP,	;EAE INSTRUCTIONS GO HERE WHEN IMPLEMENTED>
IOT:	IFE PDP8,<ADDI	RUNTIME,9>
	IFE PDP8I,<ADDI	RUNTIM,10>
	IFE PDP8L,<ADDI	RUNTIM,11>
	IFE PDP8S,<ADDI RUNTIM,80>
IFN INLINE,<LDB	AC0,[POINT 9,MB,35]	;LOAD LEAST SIGNIFICANT 9BITS OF IOT
	LSH	AC0,5
	MOVSI	AC1,-IOTN
	HLRZ	AC2,IOTIT(AC1)
	CAMN	AC0,AC2
	JRST	@IOTIT(AC1)
	AOBJN	AC1,.-3>
IFE INLINE,<JRST @IOTIT-6000(MB)>
NXIOT:	IFE ESTOP,<PUSHJ	PDP,ERROR>
	IFN ESTOP,<POPJ	PDP,>


DEFINE	IOTS
<	X 1,ION
	X 2,IOF
	X 11,RSF
	X 12,RRB
	X 14,RFC
	X 16,RRBRFC
	X 21,PSF
	X 22,PCF
	X 24,PPC
	X 26,PLS
	X 31,KSF
	X 32,KCC
	X 34,KRS
	X 36,KRB
	X 41,TSF
	X 42,TCF
	X 44,TPC
	X 46,TLS
	X 101,SMP
	X 102,SPL
	X 104,CMP
	X 201,CDF
	X 202,CIF
	IFG <MEMSIZ-10000>,<X 211,CDF
	X 212,CIF>
	X 214,RDF
	IFG <MEMSIZ-20000>,<X 221,CDF
	X 222,CIF>
	X 224,RIF
	IFG <MEMSIZ-30000>,<X 231,CDF
	X 232,CIF>
	X 234,RIB
	IFG <MEMSIZ-40000>,<X 241,CDF
	X 242,CIF>
	X 244,RMF
	IFG <MEMSIZ-50000>,<X 251,CDF
	X 252,CIF>
	IFG <MEMSIZ-60000>,<X 261,CDF
	X 262,CIF>
	IFG <MEMSIZ-70000>,<X 271,CDF
	X 272,CIF>
IFE DCS680,<	X 401,TTINCR	;680 INSTRUCTIONS
	X 402,TTI
	X 403,TTI1
	X 404,TTO
	X 405,TTO1
	X 410,TT
	X 411,TTCL
	X 412,TTSL
	X 413,TTSLC
	X 414,TTRL
	X 421,T5SKP
	X 422,TT5OFF
	X 424,TT5ON
	X 431,T8SKP
	X 432,TT8OFF
	X 434,TT8ON>
IFE PLOTER,<X 501,PLSF
	X 502,PLCF
	X 504,PLPU
	X 511,PLPR
	X 512,PLDU
	X 513,PLPRDU
	X 514,PLDD
	X 515,PLPRDD
	X 521,PLPL
	X 522,PLUD
	X 523,PLPLUD
	X 524,PLPD>
IFN DDF32,<X 601,DCMA	;DISK TYPE DF32
	X 603,DMAR
	X 605,DMAW
	X 611,DCEA
	X 612,DSAC
	X 615,DEAL
	X 616,DEAC
	X 621,DFSE
	X 622,DFSC
	X 626,DMAC>
IFE DRM08,<X 603,DRCR	;DRUM TYPE RM08
	X 605,DRCW
	X 611,DRCF
	X 612,DREF
	X 615,DRTS
	X 621,DRSE
	X 622,DRSC
	X 624,DRCN>
	X 777,NXIOT
>
IFN INLINE,<DEFINE X (A,C)
<	XWD A*40,C
IFDIF <C><ION>,<IFDIF <C><IOF>,<IFDIF <C><NXIOT>,<EXTERNAL C>>>>>

IFE INLINE,<SIZE=0
DEFINE X(A,C)<
	SIZE=A-SIZE
	REPEAT SIZE,<NXIOT>
	SIZE=A+1
	EXP	C
	IFDIF <C><ION>,<IFDIF <C><IOF>,<IFDIF <C><NXIOT>,<EXTERNAL C>>>>>


IOTIT:	IOTS
IOTN=.-IOTIT
ION:	TRON	FLAGS,PION		;IS PI TURNED ON? TURN IT ON.
	TLO	FLAGS,INTDEL	;NO. DELAY INTERRUPT ENABLE.
	POPJ	PDP,

IOF:	TRZ	FLAGS,PION		;INTERRUPT TURN OFF.
	TLZ	FLAGS,INTDEL
	POPJ	PDP,


;DATA BREAK SIMULATOR
IFE DRM08,<
EXTERNAL DCL,DFB

BREAK:	ADDI	RUNTIM,6	;ONE MEMORY CYCLE.
	MOVE	MA,DCL		;CORE ADDRESS
	TRNN	FLAGS,DRWC	;WRITING?
	JRST	BREAKR		;NO
	FETCH			;YES. GET WORD FROM CORE.
	MOVEM	MB,DFB
	TLO	FLAGS,DFBCHG	;SET DFB CHANGE FLAG.
	POPJ	PDP,

BREAKR:	MOVE	MB,DFB		;READING.
	STORE			;STORE WORD IN CORE.
	TLZ	FLAGS,DFBCHG	;CLEAR DFB CHANGE FLAG.
	AOS	DCL
	POPJ	PDP,>
;DEVICE LIST	...	DEVICE DATA BLOCK ADDRESSES

DEFINE DV(X)
<	EXP X'DATA
EXTERNAL X'DATA>

DLIST:	DV R
	DV P
	DV T
	DV K
IFE PLOTER,<DV PL>
IFN DDF32,<DV D>
IFE DRM08,<DV DM>
IFE DCS680,<DV C8
	DV C5
	DV L0
	DV L1>
	DV DR
MDLIST=DLIST-.

INTERNAL MDLISTL,DLIST

DEFINE CV(X)
<	EXP X'CDATA
EXTERNAL X'CDATA>

;CHANNEL LIST	...	FILE DATA BLOCK ADDRESSES

CLIST:	CV R
	CV P
IFE PLOTER,<CV PL>
IFN DDF32,<CV D>
IFE DRM08,<CV DI
	CV DO>
IFE DCS680,<CV LI0
	CV LO0
	CV LI1
	CV LO1
	CV PT
	CV DT>

CLISTL=.-CLIST
MCLIST=-CLISTL

INTERNAL CLISTL,MCLIST,CLIST

	END