Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/fronts.mac
There is 1 other file named fronts.mac in the archive. Click here to see a list.
COMMENT * SIMULA specification;

OPTIONS(/E:QUICK,frontstrip);

TEXT PROCEDURE frontstrip(t); TEXT t;

! IF t=/=NOTEXT THEN
! BEGIN COMMENT return t.Sub(n+1,t.Length-n), where
!	t.Sub(1,n).Strip==NOTEXT;
!
!	t.Setpos(1);
!	WHILE t.More DO
!	IF t.Getchar NE ' ' THEN
!	BEGIN
!		frontstrip:- t.Sub(t.Pos-1,t.Length-t.Pos+2);
!		t.Setpos(0);
!	END;
! END	frontstrip;

COMMENT *;! MACRO-10 code *;!

	TITLE	frontstrip
	ENTRY	frontstrip
	sall
	SUBTTL	SIMULA utility, Lars Enderin Sept 1975

;!*** Copyright 1975 by the Swedish Defence Research Institute. ***
;!*** Copying is allowed.					***

	search	simmcr,simmac
	macinit

frontstrip:
	PROC
	EXCH	XWAC1,(XTAC)
	JUMPE	XWAC1,L9	;! NOTEXT
	EXCH	XWAC2,1(XTAC)
	STACK	XTAC
	LF	X1,ZTVSP(,XWAC1)
	IF	;! Start pos = 0
		JUMPN	X1,FALSE
	THEN	;! Get byte pointer easily
		SETZ	X2,
	ELSE
		IDIVI	X1,5
	FI
	ADDI	X1,2(XWAC1)
	LF	XIAC,ZTVLNG(,XWAC1)
	CAIGE	XIAC,5
	GOTO	L2
	L	(X1)
	SKIPE	X2
	AND	mask1(X2)
	XOR	blankw(X2)
	IF	;! all blanks
		JUMPN	FALSE
	THEN	ADDI	XIAC,(X2)
		SETZ	X2,
		ADDI	X1,1
		LOOP
			SUBI	XIAC,5	;! Account for one word
			L	(X1)
		AS
			CAME	blankw
			GOTO	FALSE
			CAIL	XIAC,5
			AOJA	X1,TRUE
		SA
	FI
	IF	;! There's more
		JUMPLE	XIAC,FALSE
	THEN	;!Check next word
L2():!		HLL	X1,ptab(X2)
		LOOP
			ILDB	X1
		AS	CAIN	" "
			SOJG	XIAC,TRUE
		SA
		IF	;! Non-blanks still left
			JUMPLE	XIAC,FALSE
		THEN	;! Compute text pointer to the rest
			LF	X1,ZTVLNG(,XWAC1)
			SUBI	X1,(XIAC)
			MOVSI	X1,(X1)
			SUB	XWAC2,X1	;! New length
			HLLZS	XWAC2		;! Setpos(1)
			ADD	XWAC1,X1	;! New offset
		ELSE	;! NOTEXT
			SETZB	XWAC1,XWAC2
		FI
	ELSE	;! NOTEXT
		SETZB	XWAC1,XWAC2
	FI
	UNSTK	XTAC
	EXCH	XWAC2,1(XTAC)
L9():!	EXCH	XWAC1,(XTAC)
	RETURN
	EPROC

mask1=.-1
	BYTE	(7) 0,-1,-1,-1,-1(1) 0
	BYTE	(7) 0, 0,-1,-1,-1(1) 0
	BYTE	(7) 0, 0, 0,-1,-1(1) 0
	BYTE	(7) 0, 0, 0, 0,-1(1) 0

blankw:	ASCII	/     /
	BYTE	(7) 0," "," "," "," "(1)0
	BYTE	(7) 0,  0," "," "," "(1)0
	BYTE	(7) 0,  0,  0," "," "(1)0
	BYTE	(7) 0,  0,  0,  0," "(1)0

ptab:	POINT	7,2,-1
	POINT	7,2,06
	POINT	7,2,13
	POINT	7,2,20
	POINT	7,2,27
	POINT	7,2,34

	END;