	SUBROUTINE SEGSUM
C
C	FOR FURTHER INFORMATION CONTACT:
C
C	ROBERT WATSON
C	CISCO, INC.
C	4135 S. 100 E. AVE.
C	TULSA OK 74145
C
	INTEGER*4	ADDR,		INT4,		PC
	INTEGER*2	SEGTAB(3,50),	BLK(256)
	BYTE		SNAM(25)
	COMMON	/TSKCOM/  BLK, IREC, ISUB, PC, SEGTAB, IZRWRD, SNAM
	DATA	SEGTAB	/150*0/
	READ   (1'1) BLK
	IHDBLK = BLK(70) !VBN OF RESIDENT HEADER
	IZRBLK = BLK(70) !USUALLY HDR IS LESS THAN ONE BLK LONG
	ILDSIZ = BLK(7)
	IHDSIZ = BLK(78)
	IROBLK = 0
	IF (BLK(77) .LE. 0) GO TO 45
	IROBLK = BLK(75) + 1
	IROLEN = BLK(74)
	IROADR = BLK(76)
45	READ   (1'IHDBLK) BLK
	IZRWRD = (BLK(62) * 32) + 1 !HDR SIZE IN 32-WD BLKS
	IF (IZRWRD .LE. 256) GO TO 50
	IZRBLK = IZRBLK + 1
	IZRWRD = IZRWRD - 256
	READ   (1'IZRBLK) BLK
50	ADDR = BLK(IZRWRD+3) !ADDR OF $$OVDT FR VIR 6
	ADDR = (ADDR .AND. "177777)
	IF (ADDR .NE. 0) GO TO 70
	SEGTAB(1,1) = IZRBLK
	SEGTAB(2,1) = 0
	ADDR = ILDSIZ
	ADDR = (ADDR .AND. "177777)
	INT4 = IHDSIZ
	SEGTAB(3,1) = ((ADDR - INT4) * 64) - 1 !ENDING PC OF RW ROOT
	ISG = 2 !SET SUBSCRIPT IN CASE NEED TO ADD RO LATER
	GO TO 150
70	IBLK = (ADDR / 512) + IHDBLK
	IWRD = (ADDR .AND. "777) / 2
	IWRD = IWRD + IZRWRD
	IF (IWRD .LE. 256) GO TO 80
	IWRD = IWRD - 256
	IBLK = IBLK + 1
80	READ   (1'IBLK) BLK
	IF (IBLK .LT. 256) GO TO 90
	IBLK = IBLK + 1
	IWRD = 0
	READ   (1'IBLK) BLK
90	ADDR = BLK(IWRD+1) !ADDR OF $$SGD1 FR 2ND WD
	ADDR = (ADDR .AND. "177777)
	IF ((IWRD+5) .LE. 256) GO TO 100
	IWRD = IWRD - 256
	IBLK = IBLK + 1
	READ   (1'IBLK) BLK
100	LEN = BLK(IWRD+5) !LENGTH OF SEGMENT DESCRIPTOR IN BYTES
	IBLK = (ADDR / 512) + IHDBLK
	IWRD = (ADDR .AND. "777) / 2
	IWRD = IWRD + IZRWRD
	IF (IWRD .LE. 256) GO TO 110
	IWRD = IWRD - 256
	IBLK = IBLK + 1
110	READ   (1'IBLK) BLK
	DO 140 ISG = 1, 49
	IF ((BLK(IWRD).AND."100000) .EQ. 0) GO TO 150
	SEGTAB(1,ISG) = (BLK(IWRD) .AND. "7777) + IHDBLK !BEG. VBN
	IF (IWRD .LT. 256) GO TO 120
	IBLK = IBLK + 1
	IWRD = 0
	READ   (1'IBLK) BLK
120	IWRD = IWRD + 1
	SEGTAB(2,ISG) = BLK(IWRD) !BEG. PC
	IF (IWRD .LT. 256) GO TO 130
	IBLK = IBLK + 1
	IWRD = 0
	READ   (1'IBLK) BLK
130	IWRD = IWRD + 1
	ADDR = SEGTAB(2,ISG) !BEG. PC
	ADDR = (ADDR .AND. "177777)
	INT4 = BLK(IWRD)  !LENGTH IN BYTES
	INT4 = (INT4 .AND. "177777)
	ADDR = ADDR + INT4
	ADDR = ADDR - 1 !ENDING PC
	SEGTAB(3,ISG) = ADDR
	IWRD = IWRD + ((LEN/2)-2) !GO TO NEXT DESCRIPTOR
	IF (IWRD .LE. 256) GO TO 140
	IWRD = IWRD - 256
	IBLK = IBLK + 1
	READ   (1'IBLK) BLK
140	CONTINUE
	WRITE  (5, 145)
145	FORMAT (' SEGMENT TABLE FULL')
150	IF (IROBLK .EQ. 0) GO TO 158
	SEGTAB(1,ISG) = IROBLK !BEG. VBN OF TPA
	SEGTAB(2,ISG) = IROADR !BEG. PC
	ADDR = SEGTAB(2,ISG)
	ADDR = (ADDR .AND. "177777)
	INT4 = IROLEN
	INT4 = (INT4 .AND. "177777)
	ADDR = ADDR + INT4
	ADDR = ADDR - 1
	SEGTAB(3,ISG) = ADDR
158	DO 159 I = 1, 49
	IF (SEGTAB(1,I) .EQ. 0) GO TO 180
159	CONTINUE
	CLOSE (UNIT=1)
	WRITE  (5, 170) 7
170	FORMAT (/,' SEGMENT TABLE TOO SMALL',A1)
	STOP
180	RETURN
	END
