Google
 

Trailing-Edge - PDP-10 Archives - decuslib10-05 - 43,50337/23/lowcas.mac
There is 1 other file named lowcas.mac in the archive. Click here to see a list.
COMMENT * SIMULA specification;
OPTIONS(/E:QUICK,lowcase);
TEXT PROCEDURE lowcase(t); TEXT t;
COMMENT converts all letters [A-Z] in t to lower case in situ (no copying).
	lowcase:-t;

! IF t=/= NOTEXT THEN
! BEGIN	CHARACTER c;
!	INTEGER shift;
!	shift:= Rank('a') - Rank('A');
!	t.Setpos(1);
!	WHILE	t.More	DO
!	BEGIN	c:= t.Getchar;
!		IF	Letter(c)	THEN
!		BEGIN	IF	c>='A' AND c<='Z'	THEN
!			BEGIN	c:= Char(Rank(c)+shift);
!				t.Setpos(t.Pos-1);
!				t.Putchar(c);
!	END	END	END;
!	t.Setpos(1); ![124];
!	lowcase:- t
! END;

COMMENT *;! MACRO-10 code *;!

	TITLE	lowcase
	ENTRY	lowcase
	sall
	search	simmcr,simmac
	macinit
	SUBTTL	SIMULA utility, Lars Enderin Feb 1976

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

;! Last Edit: [124], 1976-06-21/LE


lowcase:PROC
	EXCH	XWAC1,(XTAC)
	JUMPE	XWAC1,L9	;! NOTEXT
	EXCH	XWAC2,1(XTAC)
	STACK	X2
	SETZ	X1,
	LF	X0,ZTVSP(,XWAC1)
	IF	;! Subtext
		JUMPE	X0,FALSE
	THEN	;! Split into word offset, byte offset
		IDIVI	X0,5
	FI
	ADD	X0,ptab(x1)
	ADDI	X0,(XWAC1)
	LF	X2,ZTVLNG(,XWAC1)
	LOOP
		ILDB	X1,X0
		IF	;! Upper case
			CAIG	X1,"Z"
			CAIGE	X1,"A"
			GOTO	FALSE
		THEN	;! Make it lower case
			ADDI	X1,"a"-"A"
			DPB	X1,X0
		FI
	AS
		SOJG	X2,TRUE
	SA
	UNSTK	X2
	HLLZS	XWAC2	;! [124] t.Setpos(1)
	EXCH	XWAC2,1(XTAC)	;! lowcase:-t
L9():!	EXCH	XWAC1,(XTAC)
	RETURN
	EPROC

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	;! [124]
	LIT
	END;