Google
 

Trailing-Edge - PDP-10 Archives - BB-J939D-BM - binary/psi20.b36
There are 2 other files named psi20.b36 in the archive. Click here to see a list.
MODULE psi20( %TITLE'Bliss-36 PS_INTERRUPT Example' VERSION='1(1)',
		MAIN=replay )=
BEGIN

!++
!
! FUNCTION
!
!	Example showing the use of the PS_INTERRUPT
!	linkage declaration in Bliss-36 for TOPS-20.
!
!--

LINKAGE PSI = PS_INTERRUPT;

FORWARD ROUTINE
    replay	:  NOVALUE,
    trypsi	:  NOVALUE,
    enapsi	:  NOVALUE,	! Sets up and enables the PSI.
    dispsi	:  NOVALUE,	! Disables the PSI.
    ill_inst	:  PSI NOVALUE,
    dsphdl,			! Condition Handler for the REPLAY routine
    psihdl;			! Condition Handler for interrupt  routine

LIBRARY 'TENDEF';

UNDECLARE
    $CHCRT,		! These are declared in both libraries...
    $CHFFD,
    $CHLFD;

LIBRARY 'MONSYM';

%SBTTL 'Define JSYS Calls'
!
! Copyright (C) 1982
! Digital Equipment Corporation,  Maynard, Massachusetts  01754
!
! This software is furnished under a license for use only on  a
! single computer system and may be copied only with the inclu-
! sion of the above copyright notice.  This  software,  or  any
! other  copies  thereof, may not be provided or otherwise made
! available to any other person except for use on  such  system
! and  to  one who agrees to these license terms.  Title to and
! ownership of the software shall at all times remain in DEC.
!
! The information in this software is subject to change without
! notice and should not be construed as a commitment by Digital
! Equipment Corporation.
!
! DEC assumes no responsibility for the use or  reliability  of
! its software on equipment which is not supplied by DEC.
!
!
!
!
! MODULE DESCRIPTION
!
!	This require file defines the TOPS-20 JSYS calls needed by
!	BLISS compilers running on DECsystem-20.
!
!
!
! REVISION HISTORY
!
!	4-May-82	AL	Created new module
!
!	7-May-82	AL	Added more definitions for CMDSCVs use.
!
!	10-Jun-82	AL	Add software interrupt functions
!
!
! END V3.1 BUG FIXES
!
! BLISS V4 DEVELOPMENT
!
!
! END OF REVISION HISTORY
!--
MACRO
    MJSYS(NAME,SKIPCNT,INREG,OUTREG)=
	%ASSIGN(JSYSNO,NAME)
        UNDECLARE NAME;

        LINKAGE %NAME('L_',NAME)= JSYS
                %IF NOT %NULL(INREG,OUTREG) %THEN (
		%IF NOT %NULL(INREG) %THEN RPLIST( %REMOVE(INREG) ) %FI
		%IF NOT %NULL(OUTREG) %THEN ; RPLIST( %REMOVE(OUTREG) ) %FI
			)
		%FI
		:SKIP(SKIPCNT);

	BIND ROUTINE NAME= JSYSNO: %NAME('L_',NAME); %,

    _RPL(A)= REGISTER=A %,
    RPLIST(A)[]= _RPL(A) %IF %LENGTH GTR 1 %THEN , RPLIST(%REMAINING) %FI %;

COMPILETIME
    JSYSNO = 0;

!   JSYS Name  Skips	Inputs	Outputs
!
MJSYS(	AIC,	0,	(1,2),		   )
MJSYS(	DIC,	0,	(1,2),		   )
MJSYS(	DIR,	0,	(1),		)

MJSYS(	EIR,	0,	(1),		)

MJSYS(  HALTF,  0,      ,               )

MJSYS(  PSOUT,  0,      (1),            (1))
MJSYS(	SIR,	0,	(1,2),		  )


UNDECLARE
    JSYSNO,
    %QUOTE MJSYS,
    %QUOTE RPLIST;

LITERAL
    true = 1,
    false = 0,
    ss$ill_inst = 1;	! Control-Y flag

MACRO

! PDP10_BITS - returns a literal with the specified
!	       PDP-10 bits set.

    XPDP10_BITS[BITS] = 1^(35-BITS)%,

    PDP10_BITS[] = (0 OR XPDP10_BITS(%REMAINING))%,

!OUT_CRLF - Outputs to the primary output device a 
!		carriage return, line feed.

    OUT_CRLF = PSOUT( CH$PTR(UPLIT(%CHAR(%O'15',%O'12',0)))) %;
 

OWN
    error_count : INITIAL(-1),	! Number of errors encountered
    pclev1,			! Address used to save PC during interrupts.
    levtab :  VECTOR[3]		! Priority level table used by PSI
      INITIAL(pclev1, REP 2 OF (0)),

    chntab :  VECTOR[36]	! Channel table: 
     INITIAL(REP 15 OF (0),(1^18 OR ill_inst), ! Chan.15- priority level 1,,routine ctrlc
		 REP 10 OF (0));! All other channels are not assigned.
ROUTINE replay :  NOVALUE =

    BEGIN

    PSOUT( CH$PTR(UPLIT(%ASCIZ'Expect 2 successful PSI messages:')));
    out_crlf;
    out_crlf;
    trypsi();
    out_crlf;
    PSOUT( CH$PTR(UPLIT(%ASCIZ'LAST TEST FOR PSI IS SUCCESSFUL')));

    END;
ROUTINE trypsi :  NOVALUE =
!+
! FUNCTION
!	This routine enables a condition handler.
!	It calls the routine to enable PSI for
!	an illegal instruction and then executes
!	an illegal instruction. The first illegal
!	instruction should return to outputting
!	the success message for the first test.
!	Upon executing the second illegal instruction,
!	this routine should be RETURNed from never
!	getting to the point of issuing the Failure
!	message.
!-

    BEGIN
    BUILTIN
	MACHOP;

    ENABLE dsphdl;

    enapsi();		! Enable the PSI to trap on an illegal instruction.

    MACHOP(0,0,0,0,0);	! This should cause an illegal intruction trap.

    PSOUT( CH$PTR(UPLIT(%ASCIZ'FIRST TEST FOR PSI IS SUCCESSFUL')) );

    MACHOP(0,0,0,0,0);	! This should cause an illegal intruction trap.    

    PSOUT( CH$PTR(UPLIT(%ASCIZ'PSI TEST FAILED')) );

    dispsi();		! Disable the PSI.

    HALTF();
    END;
ROUTINE enapsi :  NOVALUE =
!+
! FUNCTION
!	Enables the software interrupt system and sets up
!	the program to trap on an illegal instruction.
!-

    BEGIN

    SIR($FHSLF, ((levtab^18) OR chntab));	! Specify the PSI tables.
    EIR($FHSLF);				! Enable the PSI.
    AIC($FHSLF, PDP10_BITS($ICILI));		! Activate the interrupt channel.
    END;
ROUTINE dispsi :  NOVALUE =
!+
! FUNCTION
!	Disables the software interrupt system.
!-

    BEGIN

    DIC($FHSLF, PDP10_BITS($ICILI));		! Deactivate the interrupt channels.
    DIR($FHSLF);				! Disable the PSI.
    END;
ROUTINE ill_inst :  PSI NOVALUE =
!+
! FUNCTION
!	This is the illegal instruction interrupt handler.
!	It will SIGNAL on any illegal instruction
!	except the first one.
!-

    BEGIN
    ENABLE psihdl;
    error_count = .error_count + 1;
    IF .error_count NEQ 0
    THEN
        SIGNAL(ss$ill_inst);
    END;
ROUTINE dsphdl(sig: REF VECTOR, mech : REF VECTOR, enab : REF VECTOR) =
!+
! FUNCTION
!	Condition handler for the routine REPLAY.
!	Does an Unwind for the illegal interrupt signal.
!-

    BEGIN

    IF .sig[1] NEQ ss$ill_inst
    THEN
	RETURN false;	! Resignal for conditions other than control-Y.
    dispsi();
    SETUNWIND();
    true

    END;
ROUTINE psihdl(sig: REF VECTOR, mech : REF VECTOR, enab : REF VECTOR) =
!+
! FUNCTION
!	Condition handler for Control-Y which simply
!	resignals.
!-

    BEGIN
    RETURN false
    END;


END
ELUDOM