.MCALL .MODULE .MODULE MODES,VERSION=00,COMMENT=,IDENT=NO,LIB=YES ; Copyright (c) 1998 by Mentec, Inc., Nashua, NH. ; All rights reserved ; ; This software is furnished under a license for use only on a ; single computer system and may be copied only with the ; inclusion 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 Mentec, Inc. ; ; The information in this document is subject to change without ; notice and should not be construed as a commitment by Digital ; Equipment Corporation, or Mentec, Inc. ; ; Digital and Mentec assume no responsibility for the use or ; reliability of its software on equipment which is not supplied ; by Digital or Mentec, and listed in the Software Product ; Description. .SBTTL $AMODE - Extended mapping support routine .SBTTL $CMODE - Extended mapping support routine ;+ ; ; $AMODE ($CMODE, alternate entry used by $BCMOD) ; Checks the next argument in the argument list for a string ; specifying either U-space or S-space (strings 'U' or 'S'). ; Returns a flag to indicate specified mapping. ; ; AMODE should be a single-character string: ; U User space ; S Supervisor space ; ; Call: ; R4 = remaining argument count ; R5 -> remaining argument list ; ; Return: ; PSW = 0, no errors ; @SP = 0 if user space specified ; @SP = 1 if supervisor space specified ; PSW = 1, invalid mode specified ; R0 Invalid mode argument error code (-19.) ; ;- .PSECT SYS$I .ENABL LSB $AMODE:: $CMODE:: CLR -(SP) ;Assume user space CALL $NXADR ;Get AMODE argument BCS 20$ ;None specified... MOVB @R0,R0 ;Get the character CALL TOUPPR ;Convert it to upper case CMPB R0,#'S ;Supervisor space specified? BNE 10$ ;Nope... INC @SP ;Yes, flag it BR STKADJ ;Shuffle the stack for return 10$: CMPB R0,#'U ;User space specified? BNE ERR ;Nope... 20$: BR STKADJ .DSABL LSB .SBTTL $BCMOD - Extended mapping support routine ;+ ; ; $BCMOD ; Checks the final two arguments which might be supplied to ; routines which implement the extended mapping support. Returns ; appropriate mapping information. ; ; BMODE should be a two-character string: ; UD User data space ; SD Supervisor data space ; CD Current mode data space ; UI User instruction space ; SI Supervisor instruction space ; CI Current mode instruction space ; ; CMODE should be a one-character string: ; U User instruction space ; S Supervisor instruction space ; ; Call: ; R1 = { 0 | 1 | -> Completion routine} ; R4 = Remaining argument count ; R5 -> remaining argument list ; ; Return: ; PSW = 0, no errors ; R1 untouched if passed as { 0 | 1 } ; low bit set if supervisor mode specified in CMODE ; R4 altered ; R5 altered ; @SP Data buffer mapping mask as specified by BMODE ; ; PSW = 1, invalid mode specified ; R0 Invalid mode argument error code (-19.) ; ; Notes: ; o The mapping mask returned will always have the low two bits set ; ; o If R1 does not contain the address of a completion routine, it ; will be untouched and any CMODE argument ignored. ; ; o The default mapping for the data buffer if BMODE is not specified ; in user data space. ; ; o Uses $AMODE to parse CMODE argument ; ; o This routine assumes the call will ALWAYS use the expanded ; form of the EMT block ; ;- .LIBRARY "SRC:SYSTEM.MLB" .MCALL ..RCVD ..RCVD ;Define extra mapping bits .PSECT SYS$I .ENABL LSB $BCMOD:: MOV #^B11,-(SP) ;Ensure low two bits are on ; since the caller will be using ; the expanded request block form CALL $NXADR ;Get pointer to BMODE string BCS 50$ ;None to get... ; The following code gets the two characters into a register ; with the second character in the low byte and the first ; character in the high byte. The reason a simple MOV and SWAB ; is not used is we cannot guarantee that the string will start ; on a word boundary. MOVB (R0)+,-(SP) ;Get first character SWAB @SP ;Shift it to high byte MOVB (R0)+,@SP ;Get second character MOV (SP)+,R0 ;Return them to R0 CALL TOUPPR ;Upper case second character CMPB R0,#'I ;Data buffer in instruction space? BNE 10$ ;Nope... BIS #..ISPA,@SP ;Yes, flag it BR 20$ 10$: CMPB R0,#'D ;Data buffer in data space? BNE ERR ;Invalid argument 20$: SWAB R0 ;Now to work on first character CALL TOUPPR ;Upper case it... CMPB R0,#'S ;Supervisor mode? BNE 30$ ;Nope... BIS #..SUPY,@SP ;Yes, flag it BR 50$ 30$: CMPB R0,#'C ;Current mode? BNE 40$ ;Nope... BIS #..CURR,@SP ;Yes, flag it BR 50$ 40$: CMPB R0,#'U ;User mode? BNE ERR ;Invalid argument 50$: CMP R1,#2 ;Does R1 contain a completion address? BLO 60$ ;Nope... CALL $CMODE ;Process CMODE argument BCS ERR ;Invalid argument... BIS (SP)+,R1 ;Set mapping bit as specified STKADJ: 60$: MOV @SP,-(SP) ;Save the mask we're returning MOV 4(SP),2(SP) ;Shuffle the stack so the mask MOV (SP)+,2(SP) ; is on top when we return 70$: TST (PC)+ ;Good return, carry = 0 80$: SEC ;Error return, carry = 1 RETURN ERR: TST (SP)+ ;Dump return argument MOV #-19.,R0 ;R0 = Invalid mode error code BR 80$ .DSABL LSB .SBTTL TOUPPR - Convert from lower to upper case ;+ ; ; TOUPPR ; Converts a character to upper case ; ; Call: ; R0 = Character ; ; Return: ; R0 = Upper cased character ; ;- TOUPPR: CMPB R0,#'A!40 ;Is it in the lower case range? BLO 10$ ;Nope... CMPB R0,#'Z!40 ;Maybe, check upper limit BHI 10$ ;Nope... BICB #40,R0 ;Yes, convert to upper 10$: RETURN .END