Google
 

Trailing-Edge - PDP-10 Archives - decus_20tap5_198111 - decus/20-0143/struct.mac
There are 2 other files named struct.mac in the archive. Click here to see a list.
	UNIVERSAL  STRUCT  --  STRUCTURED PROGRAMMING MACROS
	SUBTTL	DEFINITIONS


;;	VERSION 1(0)-2

;;	WRITTEN BY ROBERT P. NIX  --  11/21/78


;;	STRUCT -- A SET OF STRUCTURED PROGRAMMING MACROS FOR
;;		THE DECSYSTEM-10 ASSEMBLER.

;;	THE CALLS:


;		%IF <CONDITIONS> ; THEN
;		  -- CODE --
;		%ELSE
;		  -- CODE --
;		%ENDIF

;			- OR -

;		%IF <CONDITIONS> ; THEN
;		  -- CODE --
;		%ENDIF


;		%WHILE <CONDITIONS> ; DO
;		  -- CODE --
;		%ENDWHILE


;		%REPEAT
;		  -- CODE --
;		%UNTIL <CONDITIONS>


;		%CASE
;		 %WHEN <CONDITIONS> ; DO
;		  -- CODE --
;		 %WHEN <CONDITIONS> ; DO
;		  -- CODE --
;		%ENDCASE


;		%LOOP
;		  -- CODE --
;		%EXITIF <CONDITIONS>
;		  -- CODE --
;		%ENDLOOP


;;	<CONDITIONS> IS DEFINED AS:

;		<[CAI, SKIP OR OTHER SKIPPING COND],AFIELD,BFIELD,COND>
;		<<CONDITIONS>,AND,<CONDITIONS>>
;		<<CONDITIONS>,OR,<CONDITIONS>>
;		<NOT,<CONDITIONS>>
	SUBTTL	DEFINITIONS FOR MACROS NEEDED INTERNALLY TO SUBSYSTEM


	LALL


	DEFINE	COND	(UCOND,T,F,%T1,%F1) <
..CCNT== 0
	IRP	UCOND,< ..CCNT== ..CCNT+1 >
	IFE	..CCNT-4,<
	  ACOND	(UCOND,T,F)  >
	IFE	..CCNT-2,<
	  ..CC== 0
	  IRP	UCOND,<
	  ..CC== ..CC+1
	  IFE	..CC-2,<
	    COND (UCOND,F,T) > > >
	IFE	..CCNT-3,<
	  ..CC== 0
	  IRP	UCOND,<
	  ..CC== ..CC+1
	  IFE	..CC-1,<
	    COND (UCOND,%T1,%F1) >
	  IFE	..CC-2,<
	    IFIDN <UCOND><AND>,<
%F1:	JRST	F
%T1:	>
	    IFIDN <UCOND><OR>,<
%T1:	JRST	T
%F1:	>
	 >
	  IFE	..CC-3,<
	    COND (UCOND,T,F) > > > >


	DEFINE	ACOND	(I,A,B,C,T,F) <
	I'C	A,B
	JRST	F
	JRST	T	>


	DEFINE	BLDSYM	(CONST,ARG) <
CONST'ARG== .
			>


	DEFINE	ORGSYM	(CONST,ARG) <
	.ORG	CONST'ARG
			>
	SUBTTL	SUBTTL	DEFINITIONS FOR %IF, %ELSE, %ENDIF



	DEFINE	%IF	(UCOND,%T,%F) <
	IFNDEF	.ILVL,<.ILVL== 0>
	COND	(<UCOND>,%T,%F)
%F:	JRST	@.+1
	BLDSYM	(.IF,\.ILVL)
	BLOCK	1
%T:
	.ILVL== .ILVL+1
			>


	DEFINE	%ELSE	(%ELS,%END) <
	IFNDEF	.ILVL,<PRINTX "ATTEMPTED %ELSE W/O %IF">
	.ILVL== .ILVL-1
	IFL	.ILVL,<PRINTX "ATTEMPTED %ELSE W/O %IF">
	IFGE	.ILVL,<
	JRST	@'%END
	ORGSYM	(.IF,\.ILVL)
	EXP	%ELS
	.ORG
	BLDSYM	(.IF,\.ILVL)
%END:	BLOCK	1
%ELS:
	.ILVL== .ILVL+1
			> >


	DEFINE	%ENDIF	(%END) <
	IFNDEF	.ILVL,<PRINTX "ATTEMPTED %ENDIF W/O %IF">
	.ILVL== .ILVL-1
	IFL	.ILVL,<PRINTX "ATTEMPTED %ENDIF W/O %IF">
	IFGE	.ILVL,<
%END:
	ORGSYM	(.IF,\.ILVL)
	EXP	%END
	.ORG
			> >
	SUBTTL	DEFINITIONS FOR %WHILE, %ENDWHILE


	DEFINE	%WHILE	(UCOND,%T,%F) <
	IFNDEF	.WLVL,<.WLVL== 0>
	BLDSYM	(.WTO,\.WLVL)
	COND	(<UCOND>,%T,%F)
%F:	JRST	@.+1
	BLDSYM	(.WLV,\.WLVL)
	BLOCK	1
%T:
.WLVL==	.WLVL+1		>


	DEFINE	%ENDWH	(%BACK,%EN) <
	IFNDEF	.WLVL,<PRINTX "ATTEMPTED %ENDWHILE W/O %WHILE">
	.WLVL== .WLVL-1
	IFL	.WLVL,<PRINTX "ATTEMPTED %ENDWHILE W/O %WHILE">
	IFGE	.WLVL,<
	ORGSYM	(.WTO,\.WLVL)
%BACK== .
	.ORG
	JRST	%BACK
%EN==	.
	ORGSYM	(.WLV,\.WLVL)
	EXP	%EN
	.ORG		> >
	SUBTTL	DEFINITIONS FOR %REPEAT, %UNTIL


	DEFINE	%REPEA <
	IFNDEF	.RLVL,<.RLVL== 0>
	BLDSYM	(.RTO,\.RLVL)
.RLVL== .RLVL+1		>


	DEFINE	%UNTIL	(UCOND,%T,%F,%TO) <
	IFNDEF	.RLVL,<PRINTX "ATTEMPTED %UNTIL W/O %REPEAT">
.RLVL==	.RLVL-1
	IFL	.RLVL,<PRINTX "ATTEMPTED %UNTIL W/O %REPEAT">
	IFGE	.RLVL,<
	COND	(<UCOND>,%T,%F)
	ORGSYM	(.RTO,\.RLVL)
%TO==	.
	.ORG
%F:	JRST	%TO
%T:			> >
	SUBTTL	DEFINITIONS FOR %CASE, %WHEN, %ENDCASE


	DEFINE	%CASE	(%CONT,%NXT) <
	IFNDEF	.CLVL,<.CLVL== 0>
	JRST	%CONT
	BLDSYM	(.CBO,\.CLVL)
	BLOCK	1
	BLDSYM	(.CNX,\.CLVL)
%NXT:	BLOCK	1
%CONT:	JRST	@'%NXT
.CLVL== .CLVL+1
			>


	DEFINE	%WHEN	(UCOND,%T,%F,%BO,%NXT,%TOP) <
	IFNDEF	.CLVL,<PRINTX "ATTEMPTED %WHEN W/O %CASE">
.CLVL==	.CLVL-1
	IFL	.CLVL,<PRINTX "ATTEMPTED %WHEN W/O %CASE">
	IFGE	.CLVL,<
	ORGSYM	(.CBO,\.CLVL)
%BO==	.
	.ORG
	JRST	@'%BO
%TOP==	.
	ORGSYM	(.CNX,\.CLVL)
	EXP	%TOP
	.ORG
	COND	(<UCOND>,%T,%F)
%F:	JRST	@'%NXT
	BLDSYM	(.CNX,\.CLVL)
%NXT:	BLOCK	1
%T:
.CLVL== .CLVL+1
			> >


	DEFINE	%ENDCA	(%BO) <
	IFNDEF	.CLVL,<PRINTX "ATTEMPTED %ENDCASE W/O %CASE">
.CLVL==	.CLVL-1
	IFL	.CLVL,<PRINTX "ATTEMPTED %ENDCASE W/O %CASE">
	IFGE	.CLVL,<
%BO==	.
	ORGSYM	(.CBO,\.CLVL)
	EXP	%BO
	.ORG
	ORGSYM	(.CNX,\.CLVL)
	EXP	%BO
	.ORG
			> >
	SUBTTL	DEFINITIONS FOR %LOOP, %EXITIF, %ENDLOOP


	DEFINE	%LOOP <
	IFNDEF	.LLVL,<.LLVL== 0>
	BLDSYM	(.LT,\.LLVL)
	.LLVL== .LLVL+1
			>


	DEFINE	%EXITI	(UCOND,%T,%F,%OUT) <
	IFNDEF	.LLVL,<PRINTX "%EXITIF W/O %LOOP">
	.LLVL== .LLVL-1
	IFL	.LLVL,<PRINTX "%EXITIF W/O %LOOP">
	IFGE	.LLVL,<
	COND	(<UCOND>,%T,%F)
%T:	JRST	@'%OUT
	BLDSYM	(.LB,\.LLVL)
%OUT:	BLOCK	1
%F:
	.LLVL== .LLVL+1
			> >


	DEFINE	%ENDLO	(%TOP,%BO) <
	IFNDEF	.LLVL,<PRINTX "%ENDLOOP W/O %LOOP">
	.LLVL== .LLVL-1
	IFL	.LLVL,<PRINTX "%ENDLOOP W/O %LOOP">
	IFGE	.LLVL,<
	ORGSYM	(.LT,\.LLVL)
%TOP== .
	.ORG
	JRST	%TOP
%BO:
	ORGSYM	(.LB,\.LLVL)
	EXP	%BO
	.ORG
			> >
	SUBTTL	END OF MODULE


	end