Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/scanin.mac
There is 1 other file named scanin.mac in the archive. Click here to see a list.
COMMENT * SIMULA specification;
OPTIONS(/E:CODE,scanint);
INTEGER PROCEDURE scanint(t);    NAME t;    TEXT t;

COMMENT Starting at t.Pos, scanint finds the next integer item and returns its
value. T.Pos is moved past the item, except if no legal item is found.
In that case, scanint returns minint, the algebraically lowest value: -2^35.
;

!*;! MACRO-10 code !*;!

	TITLE	scanint
	ENTRY	scanint
	SUBTTL	SIMULA utility, Lars Enderin Dec 1975

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


	sall
	search	simmac,simmcr,simrpa
	macinit

	;! Local definitions ;!

	result==ZBI%S
	t==result+1

scanint:PROC
	LI	XTAC,TXGI
	BRANCH	.scan
	EPROC
;! INTEGER/LONG REAL PROCEDURE .scan(t,pf);!
;! NAME t;! TEXT t;! INTEGER/LONG REAL PROCEDURE pf;!

	ENTRY	.scan
.scan:	PROC
	ST	XTAC,result(XCB)	;! Proc address
	LI	XWAC1,t
	CAIN	XTAC,TXGR
	LI	XWAC1,t+1
	HRLI	XWAC1,(XCB)
	EXEC	PHFT
	XWD	0,0
	HLRZ	XWAC3,XWAC1
	ADDI	XWAC3,(XWAC1)
	HRLZ	1(XWAC3)	;! Pos
	LD	XWAC5,(XWAC3)	;! Save old text variable
	ADDM	(XWAC3)		;! Compute rest
	MOVN
	ADDM	1(XWAC3)
	ZF	ZTVCP(XWAC3)	;! Pos:=1
	LI	XWAC1,(XWAC3)
	HRROI	XTAC,XWAC1
	PUSHJ	XPDP,@result(XCB)	;! Call get... proc
	IF	;! Error return
		JUMPL	XTAC,FALSE
	THEN	;! Result = -2^35
		MOVSI	XWAC1,400000
		SETZ	XWAC2,
	ELSE	;! Account for item by moving pos
		LF	,ZTVCP(XWAC3)
		ADDM	XWAC6
	FI
	STD	XWAC5,(XWAC3)	;! Old text var with new pos
	L	result(XCB)
	CAIN	TXGR
	ST	XWAC2,1+result(XCB)
	ST	XWAC1,result(XCB)
	BRANCH	CSEP
	EPROC

	LIT
	END;