Google
 

Trailing-Edge - PDP-10 Archives - decuslib20-01 - decus/20-0003/string.mac
There are 10 other files named string.mac in the archive. Click here to see a list.
	title STRING - simple string routines for pascal

;*******************************************
;WARNING:  This module uses KL instructions
;*******************************************

	twoseg

	search monsym,pasunv

	reloc 400000

	entry putstr,findnull
	entry byteset,bytewrite,bytepos,arrset,arrwri

;putstr(source,count,destin,offset)
;	b - source start
;	c - source size
;	d - count to move
;	e - dest start
;	f - dest size
;	g - offset

putstr:	hrli b,440700	;b _ source
	sub f,g		;f _ room in destin
	addi f,1
	camle d,f	;d _ chars to move
	move d,f
	camle d,c	
	move d,c
	hrli e,440700	;g _ destin
	subi g,1
	adjbp g,e
putstl:	sojl d,cpopj	;copy loop
	ildb t,b
	idpb t,g
	jrst putstl
cpopj:	popj p,

;findnull(source) --> offset
;	b - source start
;	c - source size
findnu:	hrli b,440700	;b _ start
	move d,c	;d _ saved size
findnl:	sojl c,findnf	;if run out, failed to find any
	ildb t,b
	jumpe t,findns
	jrst findnl

findns:	sub d,c		;d _ offset for one found
	movem d,1(p)
	popj p,

findnf:	setzm 1(p)
	popj p,

	extern getlnx,putlnx,illfn,putpgx,getchr,clofil

	filbct==30		;count left
	filbpt==27		;byte ptr
	filfps==26		;first position - for getindex only

bytnt:	exp 7b5,bytget,bytput,getlnx,putlnx,0,.+1
	exp illfn,illfn,putpgx,illfn,illfn,cpopj,cpopj,cpopj

bytget:	ildb a,filbpt(b)
	jumpe a,bytend
	jrst getchr

bytput:	move a,filcmp(b)
	idpb a,filbpt(b)
	setzm t,
	move a,filbpt(b)
	idpb t,a
	popj p,

;byteset and bytewrite work just like STRSET and STRWRITE, but take as
;arguments byte pointers for where to start reading or writing.
;They are designed to play with strings where JSYS's are also being
;used.  So READ will return EOF at a null and WRITE will put null at
;end of file.  No check for end of string is done, since the JSYS's don't.
;  b - FCB
;  c - byte pointer
;ARRSET and ARRWRITE are the same, but are used at the beginning of an
;array - they take an array as arguments instead of a byte pointer.
arrset:	hrli c,440700
bytese:	movei a,0		;normal eof
	pushj p,stropn
	jrst @filget(b)

arrwri:	hrli c,440700
bytewr:	movei a,1		;normal eof
	;jrst stropn

stropn:	move t,filtst(b)	;init if not already inited
	caie t,314157
	pushj p,initb.##
	movem c,filbpt(b)
	movem a,fileof(b)
	trc a,1
	movem a,filbad(b)
	move t,[xwd 1,norcht##]	;assume no lower case mapping
	movem t,filcht(b)
	skipe filclo(b)		;any closing needed?
	pushj p, [ setz c,		;yes - do it
	           jrst clofil]
	movei t,fl%fme		;allow format error
	movem t, filflg(b)
	hrri t,filr11(b)
	hrli t,bytnt+1
	blt t,filr99(b)		;put in dispatch
	popj p,

bytend:	move t,filbad(b)
	movem t,fileof(b)
	movem t,fileol(b)
	setzm filcmp(b)
	movei t,iox4
	movem t,filerr(b)
	popj p,

bytepo:	move t,filbpt(b)
	movem t,1(p)
	popj p,

	end