Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-01 - 43,50034/t5.c6
There are no other files named t5.c6 in the archive.
	 SUBROUTINE SIMM(RET)

C       INSTRUCTION SIMULATOR.
C       OUTPUT:  RET=0 - NO STOP POINT.
C                   =1 - STOP POINT.
        IMPLICIT INTEGER(A-Z)
      COMMON/MEM/MEM(4096),MEMROL,MEMROH,ROMF,MEMH ,MEMLIM
      COMMON/SCRATCH/REGISTER(9),SAV(9)
      EQUIVALENCE (LP,REGISTER(8)),(PC,REGISTER(9)),(ST,REGISTER(1))
      EQUIVALENCE (ST,STATUS)
      COMMON/CNTRLC/CNTRLC
      COMMON/GEN1/ IC,OP,IR,IOLINK,STOP(8),STOPC(8),CAR,RESULT,BW,CAD,
     1    BRKN,DEV,FIL,FILN,IRET,NOTYO,NOTYI,SG,SGA,SUBOPA,
     2    TYEQTY,ADSTOP,ADSTCL,ADSTFL,ADSTAD,TR1,TR2,TR3,TIME,TIMES,
     3    TTYSRC,SERMSK,SERLOW,SERHI,TYOERR,TDEV,TFIL,GROUP,GROUPA,OVR
      EQUIVALENCE(TI,T1)
      COMMON /GEN2/ PTIDEV,PTIFIL,PTODEV,PTOFIL,TIDEV,TIFIL,NOPTI,
     1    NOPTO,PUNCH,GENIOR,TYISTY
      COMMON/CONST/MH,ML,MAL,MALC,MLC,M7,M8,SCRBEG,SCREND,C2T7,C2T15,
     1    TYO,CON,TYI,BIN,TTYNAM,PTRNAM,DSKNAM,TTOFIL,TTIFIL,
     2    NUMINW,CR,LF,TAB,CHRLEN,WRDLEN,B,DOL,BLANK,EQUALS,COMMA,
     3    WM0,WM1,WM2,WM3,WM4,WM5,WM6,WM7,WM8,WM9,WM10,WM11,WM12,
     4    WM13,WM14,WM15,SL8,APC,ACC,ADR0,
     5    TSTION
      EQUIVALENCE(ETFLG,ADR0)
      COMMON/CHAR/LEGALF,NUM,COMMND,COMMNN,SHIFT,CNTRLU,RUBOUT,
     1    ALTMD1,ALTMD2,ALTMD3,DOLLFT,BLANKL ,LEGALN,NUMN,TABLFT,ICHAR,
     2    COLON,SLASH
      DIMENSION LEGALF(4),NUM(2),COMMND(40,2)
      EQUIVALENCE (CRLEFT,COMMND(25,1)),(ARO,COMMND(27,1)),
     1    (BARO,COMMND(26,1)),(LFLEFT,COMMND(29,1)),(BLF,COMMND(28,1))
      COMMON/GEN3/SOUR,DEST,SD,DD,SM,DM,SREG,DREG
      COMMON/MESAGE/MES1,MES1A,MES1B,MES1X,MES2,MES2A,MES2B,MES2X,
     1    MES3,MES3A,MES3B,MES3X,MES4,MES4X,MES5,MES5A,MES5B,
     2    MES5C,MES5D,MES5X,MES6,MES6X,MES7,MES7X,MES8,MES8A,
     3    MES8B,MES8X,MES9,MES9A,MES9B,MES9X,MES10,MES10A,
     4    MES10B,MES10X,MES11,MES11X,MES12,MES12X,MES13,MES13X,
     5    MES14,MES14X,MES15,MES15X,MES16,MES16X,MES17,MES17X,
     6    MES18,MES18X,MES19,MES19X,MES20,MES20A,MES20B,MES20C,
     7    MES20D,MES20X,MES21,MES21X,MES22,MES22X,MES23,MES23A,
     8  MES23B,MES23X,MES24,MES25,MES25X,MES26,MES26X,
     9    MES27,MES27A,MES27B,MES27C,MES27D,MES27X,MES28,MES28X,
     1  MES29,MES29A,MES29B,MES29C,MES29D,MES29E,MES29F,MES29X,
     2    MES30,MES30X,MES31,MES31X,MES32,MES32A,MES32B,MES32C,
     3    MES32D,MES32X,MES33,MES33A,MES33B,MES33C,MES33D,MES33X
     4   ,MES20E,MES20F,MES24X
      DIMENSION MES1(6),MES2(3),MES3(5),MES4(2),MES5(3),MES6(1),MES7(1),
     1    MES8(3),MES9(2),MES10(2),MES11(1),MES12(1),MES13(2),MES14(2),
     2    MES15(3),MES16(2),MES17(1),MES18(3),MES19(3),MES20(6),MES21(1)
     3   ,MES22(1),MES23(4),MES24(1),MES25(1),MES26(2),MES27(7),
     4    MES28(2),MES29(5),MES30(2),MES31(1),MES32(3),MES33(2)
	COMMON/MESAG2/MES34,MES34X,MES35,MES35X,MES36,MES36X,
     1    MES37,MES37X
	DIMENSION MES34(2),MES35(1),MES36(1),MES37(6)
        COMMON /GEN4/ DE,SE
        COMMON /GEN5/ STDEST
      COMMON /CNTRLR/ CNTRLR
       COMMON /NOTYOA/ NOTYOA
	COMMON/SINGIN/SINGIN

        COMMON/XPG/XPG,XPGI,XPGJ,TIMEX
	DIMENSION XPG(30,10)

	COMMON/DCH/DCH,DCHI,DCHJ,NUMDEV
	DIMENSION DCH(10,10)

	COMMON/POWTWO/ CT0,CT1,CT2,CT3,CT4,CT5,CT6,CT7
C
C
C	DEVICE INDEXES
C
C
	COMMON/DEVINX/DEVINX
	DIMENSION DEVINX(10,6)
C
C
	COMMON/LPOVAD/LPOVAD,LPOVFL,TRAF,WAITF
C        START AT 105. LOOPS AT 100
	 GOTO 105
C        CHECK FOR ^C-REENTER.
100      IF(CNTRLC.NE.0)GO TO 101
C        LOOK FOR ADDRESS STOP DURING LAST INSTRUCTION.
	 IF(ADSTOP.NE.IC)GO TO 111
	 IF(ADSTCL.NE.1.AND.ADSTCL.NE.3)GO TO 111
	 ADSTFL=1
	 ADSTAD=IC
111      IF(ADSTFL.EQ.0)GO TO 102
	 CALL CHA(MES27,MES27A,MES27B,ADSTOP)
	 CALL CHA(MES27,MES27C,MES27D,ADSTAD)
	 CALL TTYOS(MES27,1,MES27X,4)
	 CALL ICRWCS
	 CALL LIST(MES27,1,MES27X,2)
	 ADSTFL=0
115     CALL PREG(APC,IC)
112     CALL LIST(MES24,1,MES24X,3)
	 GO TO 1012
C        LOOK FOR A STOP-POINT.

102     I=1
109     IF(STOP(I).EQ. IC)GO TO 108
1010    I=I+1
	 IF(I.LE.8)GO TO 109
C        TEST FOR SINGLE INSTRUCTION MODE.

	IF(SINGIN.NE.0)GOTO120
C       DO AN INSTRUCTION. SAVE ALL REGISTERS.
C       CLEAR FLAGS.

105     CONTINUE
1	CALL SAVE
	IC=PC
	LPOVFL=0
	STDEST=0
	ITRAP=-1
	HALTF=0
	WAITF=0
C       CHECK PC. FETCH INSTRUCTION INTO IR.

69	CALL ODD(PC,E)
	IF(E.NE.0)GOTO 24
	CALL FMW(PC,IR,E)
	PC=PC+2
	CALL LAND(PC,MAL)
C       TRAF CAUSES TRT TRAP. CLEAR IT.
C       CHECK FOR T BIT IN STATUS.
	TRAF=0
	T1=STATUS
	CALL LAND(T1,16)
	IF(T1.NE.0)TRAF=1
C       BREAK IR INTO FIELDS FOR OP CODE DECODING
	CALL BXT(SG,IR,WM15,WM15)
	CALL BXT(OP,IR,WM14,WM12)
	CALL BXT(SUBOPA,IR,WM11,WM9)
	CALL BXT(GROUP,IR,WM14,WM9)
	CALL BXT(GROUPA,IR,WM15,WM9)
	CALL BXT(SGA,IR,WM8,WM8)
C       TEST FOR RESERVED BINARY.
	IF(OP.GE.7)GOTO 8
C	TEST FOR BINARIES
	IF(OP.GE.1)GOTO 25
C	TEST FOR EMT, TRAP
	IF(GROUPA.EQ.68)GOTO 504
C	TEST FOR CONDITIONAL BRANCHES
	IF(GROUPA.EQ.64.OR.1.LE.SUBOPA.AND.SUBOPA.LE.3)GOTO 73
C	TEST FOR BR
	IF(GROUPA.EQ.0.AND.SGA.EQ.1)GOTO 10
C	TEST FOR UNIMPLEMENTED CODES
	IF(SUBOPA.EQ.7)GOTO 8
C	TEST FOR OPERATES
	IF(GROUPA.EQ.0.AND.SGA .EQ.0)GOTO 9
C	DO A JSR,UNARY OR ROT/SHF
	CALL BXT(SREG,IR,WM8,WM6)
C	TEST FOR BAD ROT,SHF
	IF(SUBOPA.EQ.6.AND.SREG.GE.4)GOTO8
74	CALL BXT(DEST,IR,WM5,WM0)
	CALL GETMOD(DEST,DD,DM,DREG)
C	TEST FOR BAD JSR
	IF(SUBOPA.EQ.4.AND.DD+DM.EQ.0)GOTO 64
C       CALCULATE DEST EFF ADR.
	CALL GETDE(DE,E)
	IF(E.NE.0)GOTO 24
	CALL GREG(SREG,T1)
C       GO DO JSR OR UNARY OR ROT/SHF.
	GOTO(11,75,28),SUBOPA-3
	GOTO 8
C       DISPATCH TO UNARY HANDLERS.
75	GOTO(12,13,14,15,16,17,18,19),SREG+1
C
C	BINARIES
C       DECODE SOURCE ADR. FETCH SOURCE OPERAND.
C
25	CALL BXT(SOUR,IR,WM11,WM6)
        CALL GETMOD(SOUR,SD,SM,SREG)
	SGTMP=SG
	IF(OP.EQ.6)SG=0
	CALL GETSE(SE,E)
	CALL GSOR(T1,G)
C       DECODE DEST ADR.
	CALL BXT(DEST,IR,WM5,WM0)
	CALL GETMOD(DEST,DD,DM,DREG)
	CALL GETDE(DE,F)
C       IF SOURCE WAS A REGISTER, GET SOURCE AGAIN.
C       THIS FIXES THE BUG MOV R0,(R0)+
	IF(SM+SD.EQ.0)CALL GSOR(T1,G)
	IF(E+F+G.NE.0)GOTO 24
C       DISPATCH TO BINARY HANDLERS.
	GOTO(3,6,5,7,800,4,8),OP
C
C	CONDITIONAL BRANCHES
C
73	CALL GN(N )
	CALL GZ(Z )
	CALL GC(CAR)
	CALL GV(OVR)
	NOVR=OVR+1
	CALL LAND(NOVR,1)
	TF=SGA
	IF(SG.NE.0)GOTO 50
	GOTO(42,43,44),SUBOPA
50	GOTO(49,47,48,46),SUBOPA+1
C
C
C
C BEQ-NE
42	CONTINUE
	T1=Z
	GOTO 60
C BLT-GE
43	CALL LXOR(N,OVR)
	T1=N
	GOTO 60
C BLE-GT
44	CONTINUE
	CALL LXOR(N,OVR)
	CALL LOR (Z,N)
	T1=Z
	GOTO 60
C BMI-PL
49	T1=N
	GOTO 60
C BLOS-HI
47	T1=Z
	CALL LOR(T1,CAR)
	GOTO 60
C BVS-VC
48	T1=OVR
	GOTO 60
C BCS-CC, BLO-BHIS
46	T1=CAR
60	CALL LXOR(T1,TF)
	IF(T1.EQ.0)GOTO 10
	T1=IC+2
	GOTO 72
10	CALL BXT(Q,IR,WM7,WM0)
	CALL SEXT(Q)
C
C EXECUTE THE BRANCH
C
51	T1=PC
	T1=T1+(Q*2)
72	CALL LAND(T1,MAL)
	PC=T1
	CALL ODD(PC,E)
	IF(E.NE.0)GO TO 24
	GOTO 26
C
C	BINARY OPS
C
C
C MOV
C
3	CONTINUE
C       EXTEND SIGN OF SOURCE IF A BYTE.
C       IF DEST IS A REG, FORCE WORD MODE.
	IF(SG.NE.0)CALL SEXT(T1)
	IF(DM+DD.EQ.0)SG=0
C       STORE AT DEST ADR.
	CALL  SDEST(T1,E)
	IF(E.NE.0)GOTO 24
	CALL GC(CAR)
	OVR=0
	RESULT=T1
	GOTO20
C
C ADD
C
4	CONTINUE
C       IF BYTE, DO A SUB.
	IF(SGTMP.NE.0)GO TO 500
39	CONTINUE
	TIMES=TIME
	CALL  GDEST(T2,F)
	TIME=TIMES
	IF(F.NE.0)GOTO 24
40	CALL ADD(T1,T2,T3,CAR,OVR)
22	CALL SDEST(T3,E)
23	RESULT=T3
	GOTO 20
C
C SUB
C
C	SET SUBTRACT FLAG.
500	SUBA=1
	GOTO 21
C
C CMP
C
C	SET COMPARE FLAG.
6	SUBA=0
21	CONTINUE
71	CONTINUE
	TIMES=TIME
	CALL GDEST(T2,F)
	IF(SUBA.NE.0)TIME=TIMES
	IF(F.NE.0)GOTO 24
	IF(SUBA.NE.0)GOTO 35
	T3=T1
	T1=T2
	T2=T3
35	CALL SUB(T1,T2,T3,CAR,OVR)
C	SUPPRESS STORE OF DEST IF A COMPARE.
	IF(SUBA.NE.0)GOTO 22
	GOTO 23
C
C BIT
C
5	CONTINUE
	CALL GDEST(T3,E)
	IF(E.NE.0)GOTO 24
	CALL LAND(T3,T1)
	CALL GC(CAR)
	OVR=0
	GOTO 23
C
C BIC
C
7	TIMES=TIME
	CALL GDEST(T2,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	CALL LNOT(T1)
	CALL LAND(T2,T1)
501	T3=T2
502	CALL GC(CAR)
	OVR=0
	GOTO 22
C
C BIS
C
800	CONTINUE
	TIMES=TIME
	CALL GDEST(T3,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	CALL LOR(T3,T1)
	GOTO 502
C
C JSR
C
11	CONTINUE
C	FIX  JSR R,(R)+
	IF(DM.EQ.1.AND.DD.EQ.0)CALL GREG(DREG,DE)
	CALL PUSHLP(T1,E)
	IF(E.NE.0)GOTO24
	CALL PREG(SREG,PC)
	PC=DE
	CALL ODD(PC,E)
	IF(E.NE.0)GOTO 24
	GOTO 26
C
C ROT/SHIFT GROUP
C
28	I=1
27	GOTO(29,30,31,32),SREG+1
C
C ROT-R
C
29	CONTINUE
	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	CAR=T1
	CALL LAND(CAR,1)
	CALL GC(T4)
	IF(T4.EQ.0)GOTO 34
	T4=C2T7
	IF(SG.EQ.0)T4=C2T15
34	CALL BXT(T3,T1,WM15,WM1)
	T3=T3+T4
	CALL SC(CAR)
	OVR=0
	IF(T4.NE.0)OVR=1
	CALL LXOR(OVR,CAR)
	CALL SDEST(T3,E)
	IF(E.NE.0)GOTO 24
33	CONTINUE
	GOTO 23
C
C ROT-L
C
30	CONTINUE
	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	T2=C2T7
	IF(SG.EQ.0)T2=C2T15
	CAR=T1
	CALL LAND(CAR,T2)
	CALL GC(T4)
	T3=0
	CALL BTX(T3,WM15,WM1,T1)
	T3=T3+T4
	CALL SC(CAR)
	OVR=T3
	CALL LAND(OVR,T2)
	CALL LXOR(OVR,CAR)
	CALL SDEST(T3,E)
	IF(E.NE.0)GOTO 24
36	CONTINUE
	GOTO 23
C
C SHIFT-R
C
31	CONTINUE
	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	CAR=T1
	CALL LAND(CAR,1)
	CALL SC(CAR)
	T2=C2T7
	IF(SG.EQ.0)T2=C2T15
	T4=T1
	CALL LAND(T4,T2)
	CALL BXT(T3,T1,WM15,WM1)
	T3=T3+T4
	CALL SDEST(T3,E)
	IF(E.NE.0)GOTO 24
	OVR=0
	IF(T4.NE.0)OVR=1
	CALL LXOR(OVR,CAR)
37	CONTINUE
	GOTO 23
C
C SHIFT-L
C
32	CONTINUE
	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	T2=C2T7
	IF(SG.EQ.0)T2=C2T15
	CAR=T1
	CALL LAND(CAR,T2)
	CALL SC(CAR)
	T3=0
	CALL BTX(T3,WM15,WM1,T1)
	CALL SDEST(T3,E)
	IF(E.NE.0)GOTO 24
	OVR=T3
	CALL LAND(OVR,T2)
	CALL LXOR(OVR,CAR)
38	CONTINUE
	GOTO 23
C
C UNARIES
C
C
C CLR
C
12	CONTINUE
	RESULT=0
	CALL SDEST(RESULT,E)
	IF(E.NE.0)GOTO 24
	CAR=0
	OVR=0
	GOTO 20
C
C COM
C
13	TIMES=TIME
	CALL  GDEST(T3,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	CALL LXOR(T3,MAL)
	CAR=1
	OVR=0
	GOTO 22
C
C INC
C
14	T2=1
41	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	CALL ADD(T1,T2,T3,T4,OVR)
	CALL GC(CAR)
	GOTO 22
C
C DEC
C
C	ADD A -1.
15	T2=MAL
	GOTO 41
C
C NEG
C
C	PERFORM DEST=0-DEST.
16	SUBA=1
	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	T2=0
	GOTO 35

C
C ADC
C
17	CONTINUE
	CALL GC(T1)
	GOTO 39
C
C SBC
C
18	SUBA=1
	CALL GC(T1)
	GOTO 71
C
C TST
C
19	T1=0
	GOTO 39
C
C OPERATES (INCLUDING JMP AND SWAB)
C
9	CALL BXT(X,IR,WM4,WM0)
	CALL BXT(SUBOPB,IR,WM7,WM5)
	IF(SUBOPB.EQ.0)GOTO 65

	IF(SUBOPB.EQ.4)GOTO 66
	IF(SUBOPB.EQ.5)GOTO 67
	IF(SUBOPB.EQ.2.OR.SUBOPB.EQ.3.OR.SUBOPB.GE.6)GOTO 90
	GOTO 8
C	DO TO JMP OR SWAB
C	CALC DEST EFF ADR.
90	CALL BXT(DEST,IR,WM5,WM0)
	CALL GETMOD(DEST,DD,DM,DREG)
C	CHECK FOR ILLEGAL JMP.
	IF(DD+DM.EQ.0.AND.SUBOPB.LT.6)GOTO 64
	CALL GETDE(DE,E)
	IF(E.NE.0)GOTO 24
	IF(SUBOPB.GE.6)GOTO 91
C	DO A JMP.
C	FIX  JMP (R)+
	IF(DD.EQ.0.AND.DM.EQ.1)CALL GREG(DREG,DE)
	PC=DE
	CALL ODD(PC,E)
	IF(E.NE.0)GOTO 24
	GOTO 26
C	DO A SWAB
91	TIMES=TIME
	CALL GDEST(T1,E)
	TIME=TIMES
	IF(E.NE.0)GOTO 24
	T3=0
	CALL BXT(T3,T1,WM15,WM8)
	CALL BTX(T3,WM15,WM8,T1)
	CALL SDEST(T3,E)
	CAR=0
	OVR=0
	SG=1
	GOTO 23
C	DISPATCH TO OPERATES.
65	IF( X.GT.5)GOTO 8
	GOTO(68,94,76,52,53,54),X+1
C
C HALT-WAIT
94	WAITF=1
	GOTO 26
68	HALTF=1
	GOTO 26
C	DO THE HALT. DISPLAY R0.
107	CALL CWA(MES2,MES2A,MES2B,PC)
	CALL TTYOS(MES2,1,MES2X)
	CALL ICRWCS
	CALL LIST(MES2,1,MES2X,4)
	CALL GREG(0,I)
	CALL CWA(MES9,MES9A,MES9B,I)
	CALL LIST(MES37,1,MES37X,1)
	CALL LIST(MES9,1,MES9X,3)
1012	CALL LIST(MES6,1,1,1)
1013	RET=0
	RETURN
C
C RTI
C
76	CALL POPLP(PC,E)
	CALL POPLP(STATUS,F)
	CALL ODD(PC,T1)
	IF(T1+E+F.NE.0)GOTO 24
	GOTO 26
C
C TRT
C
52	CONTINUE
	ITRAP=12
	GOTO 26
C
C IOT
C
53	CONTINUE
	ITRAP=16
	GOTO 26
C
C RESET
C
54	CONTINUE
	CALL RESET
	GOTO 26
C
C RTS
C
66	DREG=X
	IF(X.GT.7)GOTO 8
	CALL GREG(DREG,T2)
	CALL ODD(T2,E)
	IF(E.NE.0)GOTO 24
	PC=T2
	CALL POPLP(T1,E)
	IF(E.NE.0)GOTO 24
	CALL PREG(DREG,T1)
	GOTO 26
C
C CC-DIDDLES
C
67	M=0
	IF(X.GT.15)M=1
	DO 81 I=1,4
	J=WRDLEN-I
	CALL BXT(K,X,J,J)
	IF(K.EQ.0)GOTO 81
	GOTO(84,85,86,87),I
84	CALL SC(M)
	GOTO 81
85	CALL SV(M)
	GOTO 81
86	CALL SZ(M)
	GOTO 81
87	CALL SN(M)
81	CONTINUE
	GOTO 26
C
C EMT,TRAP
C
504	CONTINUE
	ITRAP=24
	IF(SGA.NE.0)ITRAP=28
	GOTO 26
C
C END OF INSTRUCTION-SET CC-S.
C
20	CALL NRMSET
C	DO THE TRACE FUNCTION.
26	IF(TR3.EQ.0)GOTO 61
	IF(IC.LT.TR1.OR.IC.GT.TR2)GOTO 61
	CALL CWA(MES29,MES29A,MES29B,IC)
	CALL CWA(MES29,MES29C,MES29D,IR)
	CALL GC(I)
	CALL GV(J)
	CALL GN(K)
	CALL GZ(L)
	T1=  ((I*8+J)*8+K)*8+L
	CALL CWA(MES29,MES29E,MES29F,T1)
	CALL ICRWCS
	CALL LIST(MES29,1,MES29X,4)
C	UPDATE PC AND GO TO NEXT INST.
61	CONTINUE
	CALL LAND(PC,MAL)
	IC=PC
	TIMEX=TIMEX+1
	STDEST=0
C	CHECK FOR A TRAP.
	IF(ITRAP.GE.0)GOTO 55
C	CHECK FOR SP OVERFLOW.
	IF(LPOVFL.EQ.0)GOTO 92
	IF(ETFLG.EQ.0)GOTO 62
	ITRAP=4
	GOTO 55
C	CHECK FOR HALT OR T-BIT TRAP.
92	IF(HALTF.NE.0)GOTO 107
	IF(TRAF.EQ.0)GOTO 56
	ITRAP=12
	GOTO 55
56	CONTINUE
C
C DO THE DEVICE SIMULATIONS AND TEST FOR
C	INTERRUPT REQUEST.
C
510	CONTINUE
	CALL LSRKBD
	CALL TTY
	CALL HSR
	CALL HSP
C	SORT THE INTERRUPT REQUESTS.
	CURPR=0
	CURI=0
	CALL GETPRI(MP)
	DO 520 I=1,NUMDEV
	IF(DCH(I,5).EQ.0)GOTO 520
	J=DCH(I,3)
	IF(J.LE.MP.OR.J.LE.CURPR)GOTO 520
	CURPR=J
	CURI=I
520	CONTINUE
C	CHECK FOR NO INTERRUPT REQUEST.
	IF(CURI.EQ.0)GOTO 521
	DCH(CURI,5)=0
	ITRAP=DCH(CURI,4)
	WAITF=0
	GOTO 55
C	CHECK FOR WAIT. IF A WAIT,
C	KEEP DOING DEVICE SIMULATIONS UNTIL
C	AN INTERRUPT IS REQUESTED OR UNTIL
C	A ^C-REENTER OCCURS.
521	CONTINUE
	IF(WAITF.EQ.0)GOTO 100
	IF(CNTRLC.NE.0)GOTO 101
	TIMEX=TIMEX+1
	GOTO 56
C
C CONTROL-C SEQUENCE
C
101	CNTRLC=0
	WAITF=0
C	FORCE A HALT.
	GOTO 107
C
C BAD MEM-REF, STACK OVERFLOW, ETC.
C
24	IF(ETFLG.EQ.0)GOTO 62
	ITRAP=4
	GOTO 26
C	TRAP NOT ENABLED. RESTORE REGISTERS. PRINT MESSAGE.
C	RETURN TO ODT.
62	CALL RESTOR
	IC=PC
	CALL LAND(IC,MAL)
	CALL CHA(MES1,MES1A,MES1B,IC)
	CALL TTYOS(MES1,1,MES1X)
	CALL ICRWCS
	CALL LIST(MES1,1,MES1X,4)
93	LPOVFL=0
	TRAF=0
	WAITF=0
	ITRAP=-1
	GO TO 1012
C
C BAD OP-CODE
C
64	CONTINUE
	ITRAP=4
	IF(ETFLG.NE.0)GOTO 26
	PC=IC
	CALL CHA(MES3,MES3A,MES3B,IC)
	CALL TTYOS(MES3,1,MES3X)
	CALL ICRWCS
	CALL LIST(MES3,1,MES3X,4)
	GOTO 93
C
C STOP-POINT
C
108	PC=IC
C	DECREMENT PROCEED COUNT. STOP IF 0.
	STOPC(I)=STOPC(I)-1
	IF(STOPC(I).NE.0)GO TO 1010
	BRKN=I
	STOPC(I)=1
	CALL CHA(MES5,MES5A,MES5B,IC)
	CALL CHA(MES5,MES5C,MES5D,I-1)
	CALL TTYO(MES6,1,MES6X,2)
	CALL TTYO(MES5,1,MES5X,3)
	CALL ICRWCS
	CALL LIST(MES5,1,MES5X,4)
	CALL LIST(MES6,1,1,1)
	RET=1
	RETURN
C
C	RESERVED INSTRUCTION TRAP HANDLER-PUSH ST,PC. VECTOR AT LOC 10(OCTAL).
C
8	CONTINUE
	ITRAP=8
	GOTO 26
C
C	GENERAL TRAP HANDLER -- INTERNAL TRAPS, INTERRUPTS.
C
55	CALL ODD(LP,E)
	IF(E.NE.0)GOTO 103
C	SAVE CURRENT SP OVERFLOW FLAG.
	TMPF=LPOVFL
	LPOVFL=0
	CALL PUSHLP(ST,E)
C	ON "ERROR ON ERROR", HALT.
	IF(E.NE.0)GOTO 103
	CALL PUSHLP(PC,E)
	IF(E.NE.0)GOTO 103
	CALL FMW(ITRAP,PC,E)
	IF(E.NE.0)GOTO 103
	CALL FMW(ITRAP+2,ST,E)
	IF(E.NE.0)GOTO 103
	CALL ODD(PC,E)
	IF(E.NE.0)GOTO 103
	TRAF=0
	WAITF=0
	HALTF=0
	ITRAP=-1
	IF(LPOVFL.EQ.0)GOTO 57
C	IF SP OVERFLOW OCCURRED DURING TRAP AND
C	OVERFLOW WAS NOT SET AT START OF TRAP,
C	GO BACK AND TRAP AGAIN.
	IF(TMPF.EQ.0)GOTO 55
57	TMPF=0
	IC=PC
	GOTO 100
C	ERROR ON ERROR
103	CONTINUE
	CALL LAND(PC,MAL)
	GOTO 107
C
C  SINGLE INST MODE
C
120	SINGIN=2
	CALL ICRWCS
	GOTO 1012
	END