	.mcall	.MODULE
	.MODULE	PPN,comment=<TSX PPN>,lib=yes,release=V09,version=05

;**************************************************************;
;                                                              ;
;   Copyright (c) 1988            Bob Schor                    ;
;                                 Eye and Ear Hospital         ;
;                                 230 Lothrop St.              ;
;                                 Pittsburgh, PA   15213       ;
;                                                              ;
; All rights reserved.  May not be copied without this notice. ;
;                                                              ;
;**************************************************************;

;Returns two-word PPN of current job to Pascal from TSX.  If TSX not
;running, returns 0, 0.  Will work with both RT-11 (Version 5.0
;and later) and TSX (version 5 and later).

;b schor	october, 1988	After tsxpas, v8.6

;modifications --
;	may, 1989	Pascal psects, P$CODE and LOCAL, added
;	may, 1989	Psect declarations before SUMAC call

;define our .psects before calling SUMAC to force ours low

	.psect	p$code	ro,i,lcl,rel,con
	.psect	local	rw,d,lcl,rel,con

;uses SUMAC for structured macro code

	.library	/lib:sumac/	;use external macro definition file

	.mcall	SUMAC
	SUMAC

; Uses Oregon Software PASMAC modules for Pascal compatibility.

	.library	/lib:pasmac/	;use Pascal library file

	.mcall	PASMAC
	PASMAC			;defines PASMAC library

; The following macros are included --
; 	PROC	FUNC	PARAM	VAR	SAVE	BEGIN	ENDPR
; In addition, the standard types are defined

	.dsabl	gbl			;if undefined symbol, force error


HEAD	sysmac, <system macros>
	.mcall	.GVAL			;get value from monitor


HEAD	offset, <monitor offsets>
	sysgen	=	372		;offset to sysgen features
	jobnum	=	-2		;offset for current job number
	proj.	=	-10.		;project number
	prog.	=	-12.		;programmer number

HEAD	syscom, <system communications>
	jsw	=	44		;job status word
	errbyt	=	52		;EMT error byte
	sysptr	=	54		;start of RMON

	.sbttl	---
	.page
	.sbttl	ppn
	.sbttl	---

	.psect	p$code

; The following functions/procedures will be defined by this routine.
; The calling routine should include declarations similar to those in
; this comment.

; PROCEDURE ppn (var proj, prog : integer); EXTERNAL;

PROC	ppn
PARAM	proj, address
PARAM	prog, address

SAVE	r0

BEGIN
	.GVAL	#emtarg, #sysgen	;return sysgen options
	tst	r0			;high bit set if TSX
	IF	pl			;if running RT-11,
		clr	@proj(sp)	;return 0, 0
		clr	@prog(sp)
	ELSE
		.GVAL	#emtarg, #proj.	;get project number
		mov	r0, @proj(sp)
		.GVAL	#emtarg, #prog.	;get programmer number
		mov	r0, @prog(sp)
	ENDIF
ENDPR

	.sbttl	------------------
	.page
	.sbttl	Internal variables
	.sbttl	------------------

	.psect	local

LABEL	emtarg, <emt argument storage>
	.blkw	6

LABEL	modnam, <module name>
	.NLCSI				;generates .asciz module string
	.even

	ENDEND

	.end
