	.title	k11deb	debugging support for kermit-11
	.ident	/1.0.01/
	.psect


;	21-May-84  22:07:50  Brian Nelson
;
;	Copyright (C) 1984  Change Software, Inc.





	.if ndf, K11INC
	.ift
	.include	/IN:K11MAC.MAC/
	.endc

	.psect	$code


	.enabl	gbl



	chr	=	1
	int	=	2

	.psect	$addr	,ro,d,lcl,rel,con
texadr::
	.psect	$addr1	,ro,d,lcl,rel,con
virtad:
	.psect	$type	,ro,d,lcl,rel,con
symtyp:
	.psect	$size	,ro,d,lcl,rel,con
symsiz:

	.psect	$code


	.macro	entry	name,type,size
	.save
	.if b	,name
	.ift
	.psect	$addr	,ro,d,lcl,rel,con
	.word	0
	.iff
	.dsabl	lc
	.psect	$name	,ro,d,lcl,rel,con
	$$ = .
	.asciz	#name#
	.psect	$addr	,ro,d,lcl,rel,con
	.word	$$
	.psect	$addr1	,ro,d,lcl,rel,con
	.word	name
	.psect	$type	,ro,d,lcl,rel,con
	.word	type
	.psect	$size	,ro,d,lcl,rel,con
	.word	size
	.enabl	lc
	.endc
	.restore
	.endm	entry



	.sbttl	define the symbol names


	entry	<$image>, int, 1
	entry	<albuff>, int, 1
	entry	<altcon>, int, 1
	entry	<argbuf>, int, 1
	entry	<argpnt>, int, 1
	entry	<at$acc>, int, 1
	entry	<at$are>, int, 1
	entry	<at$bil>, int, 1
	entry	<at$bsi>, int, 1
	entry	<at$cre>, int, 1
	entry	<at$dis>, int, 1
	entry	<at$enc>, int, 1
	entry	<at$fab>, int, 15
	entry	<at$for>, int, 1
	entry	<at$id>,  int, 1
	entry	<at$len>, int, 1
	entry	<at$xle>, int, 1
	entry	<at$pas>, int, 1
	entry	<at$pr0>, int, 1
	entry	<at$pr1>, int, 1
	entry	<at$sys>, int, 2
	entry	<at$typ>, int, 1
	entry	<at$val>, int, 1
	entry	<atrctx>, int, 1
	entry	<binmod>, int, 1
	entry	<bintyp>, chr, 4*40
	entry	<cccnt>,  int, 1
	entry	<chario>, int, 1
	entry	<chksiz>, int, 1
	entry	<chktyp>, int, 1
	entry	<cmdadr>, int, 1
	entry	<cmdbuf>, int, 1
	entry	<cmdlun>, int, 1
	entry	<cmdnum>, int, 1
	entry	<conesc>, int, 1
	entry	<conpar>, chr, 20
	entry	<consts>, int, 2
	entry	<do8bit>, int, 1
	entry	<dolong>, int, 1
	entry	<doattr>, int, 1
	entry	<debug>,  int, 1
	entry	<defdir>, chr, filsiz+2
	entry	<doauto>, int, 1
	entry	<do8bit>, int, 1
	entry	<dorpt> , int, 1
	entry	<duplex>, int, 1
	entry	<en$siz>, int, 1
	entry	<errtxt>, chr, 102
	entry	<filnam>, chr, filsiz+2
	entry	<handch>, int, 1
	entry	<image>,  int, 1
	entry	<index>,  int, 1
	entry	<inopn>,  int, 1
	entry	<inserv>, int, 1
	entry	<jobtyp>, int, 1
	entry	<kbiost>, int, 2
	entry	<linkst>, int, 1
	entry	<logfil>, chr, 40
	entry	<logstr>, chr, 40
	entry	<maxtry>, int, 1
	entry	<mcrcmd>, int, 1
	entry	<modem> , chr, 40
	entry	<numtry>, int, 1
	entry	<oldtry>, int, 1
	entry	<outlun>, int, 1
	entry	<outopn>, int, 1
	entry	<paknum>, int, 1
	entry	<parity>, int, 1
	entry	<pauset>, int, 1
	entry	<pcnt.r>, int, 34
	entry	<pcnt.s>, int, 34
	entry	<pnhead>, int, 1
	entry	<procty>, int, 1
	entry	<procom>, int, 1
	entry	<proflg>, int, 1
	entry	<prompt>, chr, 40
	entry	<ranerr>, int, 1
	entry	<rawfil>, int, 1
	entry	<reccnt>, int, 1
	entry	<recpar>, chr, 20
	entry	<reclng>, int, 1
	entry	<recwin>, int, 1
	entry	<remote>, int, 1
	entry	<rptquo>, int, 1
	entry	<rsx32>	, int, 1
	entry	<rtwork>, int, 10
	entry	<rtflow>, int, 1
	entry	<rtvol> , int, 1
	entry	<sencnt>, int, 1
	entry	<sendat>, int, 1
	entry	<sendly>, int, 1
	entry	<senlng>, int, 1
	entry	<senwin>, int, 1
	entry	<senpar>, chr, 20
	entry	<sermod>, int, 1
	entry	<sertim>, int, 1
	entry	<serwai>, int, 1
	entry	<setrec>, chr, 20
	entry	<setsen>, chr, 20
	entry	<size>,   int, 1
	entry	<skipfl>, int, 1
	entry	<recsop>, int, 1
	entry	<sensop>, int, 1
	entry	<sparsz>, int, 1
	entry	<srcnam>, chr, filsiz+2
	entry	<state>,  int, 1
	entry	<sy.ini>, int, 1
	entry	<tcdlu>,  int, 1
	entry	<testc>,  int, 1
	entry	<times>,  int, 4
	entry	<tists>,  int, 2
	entry	<tmperr>, int, 1
	entry	<totp.r>, int, 34
	entry	<totp.s>, int, 34
	entry	<tsxflg>, int, 1
	entry	<trace>,  int, 1
	entry	<ttcons>, chr, 20
	entry	<ttdial>, chr, 20
	entry	<ttname>, chr, 20
	entry	<umddef>, int, 1
	entry	<vttype>, int, 1
	entry	<xgottn>, int, 1
	entry	<xmode>,  int, 1
	entry




	.sbttl	the real work comes next
	.enabl	lsb
	.psect	$code


c$disp::mov	argbuf	,r0		; locate the symbol in directory
	cmpb	@r0	,#'0		; /45/ Numeric ?
	blo	5$			; /45/ no
	cmpb	@r0	,#'7		; /45/ Numeric ?
	bhi	5$			; /45/ No
	calls	octval	,<r0>		; /45/ Yes, get the address
	octout	@r1			; /45/ Dump the data
	message				; /45/ crlf
	br	100$			; /45/ Exit
5$:	cmpb	@r0	,#'*		; dump everything today ?
	bne	20$			; no
	clr	r0			; yes, start with first one
10$:	tst	texadr(r0)		; keep going until address of zero
	beq	100$			; exit
	call	prtsym			; print the symbol out
	add	#2	,r0		; next please
	message				; a cr/lf
	br	10$			; next please

20$:	call	findsy			; find the symbol now
	tst	r0			; found it ?
	bmi	90$			; no
	call	prtsym			; dump it please
	br	100$			; bye

90$:	message	<Can't find symbol in internal STB>,cr
100$:	message
	return
	
	.dsabl	lsb



	.sbttl	print the contents out
	.enabl	lsb

;	input:	r0	offset


prtsym:	save	<r0,r1,r2,r3,r4,r5>	; save this
	sub	#20	,sp		; allocate a small text buffer
	mov	sp	,r3		; and a pointer
	mov	r0	,r5		; insure we don't zap offset
	print	texadr(r5)		; print the symbol name
	mov	symtyp(r5),r4		; get the class of symbol
	asl	r4			; times 2 for word indexing
	print	200$-2(r4)		; format it a bit
	deccvt	symsiz(r5),r3,#4	; print the data item size
	print	r3	,#4		; print that out
	message				; crlf
	message				; crlf
	jsr	pc	,@190$-2(r4)	; call correct formatter routine
	message				; extra crlf
	add	#20	,sp
	unsave	<r5,r4,r3,r2,r1,r0>
	return
	
	

	.save
	.psect	$PDATA	,D
190$:	.word	pbyte,pint
200$:	.word	210$,220$
210$:	.asciz	/  Byte data,  size /
220$:	.asciz	/  Word data,  size /
	.even
	.restore

	.dsabl	lsb


	.sbttl	format for byte and integer data
	.enabl	lsb


pbyte:	sub	#20	,sp		; a buffer to use today
	mov	symsiz(r5),r1		; format byte data please
	beq	390$			; exit
	mov	virtad(r5),r5		; get the base address
310$:	mov	#20	,r3		; maximum of 16 items per line
320$:	mov	sp	,r2		; pointer to local buffer
	movb	#40	,(r2)+		; a leading space
	clr	r4			; get the next byte please
	bisb	(r5)+	,r4		; without sign extension
	mov	r4	,r0		; copy it
	ash	#-6	,r0		; get the high two bits now
	bic	#^C3	,r0		; mask the lower bits please
	add	#'0	,r0		; convert
	movb	r0	,(r2)+		; and copy
	mov	r4	,r0		; copy it
	ash	#-3	,r0		; get the high two bits now
	bic	#^C7	,r0		; mask the lower bits please
	add	#'0	,r0		; convert
	movb	r0	,(r2)+		; and copy
	mov	r4	,r0		; copy it
	bic	#^C7	,r0		; mask the lower bits please
	add	#'0	,r0		; convert
	movb	r0	,(r2)+		; and copy
	clrb	@r2			; at last, .asciz
	mov	sp	,r2		; restore buffer pointer and print
	print	r2			; simple
	dec	r1			; anything else to print
	beq	330$			; no
	sob	r3	,320$		; yes, next on the line please
	message				; filled the line
	br	310$			; next line
330$:	message				; a final cr/lf
390$:	add	#20	,sp		; release the local buffer
	return				; and exit
	


pint:	mov	symsiz(r5),r1		; get the number of data elements
	beq	490$			; nothing to do at all
	mov	virtad(r5),r2		; get the address of what to print
410$:	mov	#5	,r3		; number of items per line
420$:	decout	(r2)			; dump it
	message	<(>
	octout	(r2)+
	message	<)>
	dec	r1			; all done yet ?
	beq	430$			; yes, exit
	sob	r3	,420$		; not done, print next item
	message				; a cr/lf
	br	410$			; next line of printinh
430$:	message				; last cr/lf
490$:	return				; all done, exit

	.dsabl	lsb



	.sbttl	locate symbol offset in index




findsy:	save	<r1,r2,r3,r4,r5>	; save all the registers
	sub	#20	,sp		; allocate a buffer for upcase cvt
	mov	sp	,r2		; and allocate a pointer
	copyz	r0,r2,#10		; and copy the data over
	strlen	r2			; get the string length now
	calls	cvt$$	,<r2,r0,#40>	; convert lower to upper case now
	mov	r0	,r4		; anything there ?
	beq	90$			; no
	
	clr	r5			; initial index here
10$:	mov	texadr(r5),r1		; point to the text now
	beq	90$			; if eq, we hit the end of it all
	strlen	r1			; get the length of that text
	cmp	r0	,r4		; exact match on the length ?
	bne	30$			; no, try again please
	mov	r2	,r3		; saved pointer to text
20$:	cmpb	(r3)+	,(r1)+		; check for exact match on characters
	bne	30$			; no
	sob	r0	,20$		; yes, next please
	br	40$			; a match
30$:	add	#2	,r5		; no match, advance to the next address
	br	10$			; next please

40$:	mov	r5	,r0		; return index in r0
	br	100$			; bye

90$:	mov	#-1	,r0		; no match, return index of -1
100$:	add	#20	,sp		; pop local buffer and exit
	unsave	<r5,r4,r3,r2,r1>	; pop all registers we used
	return


	
	.end
