	.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.



	.include	/IN:K11MAC.MAC/
	.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	<argbuf>, chr, 120
	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$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	<cccnt>,  int, 1
	entry	<chksiz>, int, 1
	entry	<chktyp>, int, 1
	entry	<cmdadr>, int, 1
	entry	<cmdbuf>, chr, 120
	entry	<cmdlun>, int, 1
	entry	<cmdnum>, int, 1
	entry	<conesc>, int, 1
	entry	<conpar>, chr, 20
	entry	<consav>, chr, 20
	entry	<consts>, int, 2
	entry	<do8bit>, 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	<errtxt>, chr, 102
	entry	<filnam>, chr, filsiz+2
	entry	<handch>, int, 1
	entry	<hlpbuf>, chr, 120
	entry	<image>,  int, 1
	entry	<index>,  int, 1
	entry	<inopn>,  int, 1
	entry	<inserv>, int, 1
	entry	<kbiost>, int, 2
	entry	<linkst>, int, 1
	entry	<logfil>, chr, 40
	entry	<maxtry>, int, 1
	entry	<mcrcmd>, int, 1
	entry	<numtry>, int, 1
	entry	<oldtry>, int, 1
	entry	<outlun>, int, 1
	entry	<outopn>, int, 1
	entry	<packet>, chr, 210
	entry	<paknum>, int, 1
	entry	<parity>, int, 1
	entry	<pauset>, int, 1
	entry	<pcnt.r>, int, 34
	entry	<pcnt.s>, int, 34
	entry	<prompt>, chr, 40
	entry	<ranerr>, int, 1
	entry	<reccnt>, int, 1
	entry	<recpar>, chr, 20
	entry	<recpkt>, chr, 210
	entry	<remote>, int, 1
	entry	<rptquo>, int, 1
	entry	<rtque>,  int, 12*6
	entry	<rtwork>, int, 10
	entry	<sencnt>, int, 1
	entry	<sendat>, int, 1
	entry	<sendly>, int, 1
	entry	<senpar>, chr, 20
	entry	<sermod>, int, 1
	entry	<sertim>, int, 1
	entry	<setrec>, chr, 20
	entry	<setsen>, chr, 20
	entry	<size>,   int, 1
	entry	<skipfl>, int, 1
	entry	<sparsz>, int, 1
	entry	<srcnam>, chr, filsiz+2
	entry	<state>,  int, 1
	entry	<sy.ini>, int, 1
	entry	<testc>,  int, 1
	entry	<tists>,  int, 2
	entry	<totp.r>, int, 34
	entry	<totp.s>, int, 34
	entry	<trace>,  int, 1
	entry	<ttcons>, chr, 20
	entry	<ttdial>, chr, 20
	entry	<ttname>, chr, 20
	entry	<ttparm>, chr, 50
	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	,#'*		; 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
	
	

190$:	.word	pbyte,pint
200$:	.word	210$,220$
210$:	.asciz	/  Byte data,  size /
220$:	.asciz	/  Word data,  size /
	.even

	.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	#12	,r3		; number of items per line
420$:	decout	(r2)+			; dump it
	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
