;++MISC.MAR ; ; FACILITY: ; Fermilab Accelerator Control System. ; General purpose macro library. ; ; ABSTRACT: ; This file contains miscellaneous macros. ; ; ENVIRONMENT: ; Input to generate the FERMILIB.MLB macro library. ; ;-- ; ; MODIFICATION HISTORY: ; ; AUTHOR: F. Nagy Creation date: 24-Oct-82 ; ; V01.00 24-Oct-82 FJN Created from NETMACROS.MAR ; ;+ CASE ; ; CASE src, {,TYPE=W} {,LIMIT=#0} {,NMODE=S^#} ; ; Generates a CASEx instruction (x is given by TYPE) and the case table ; dispatch list. ; ; src source argument on which the CASE will dispatch to the ; correct label ; ; disp-list list of labels to which control will transferred by the ; CASE instruction for sequential values of the source ; ; TYPE data type of the CASE, default is WORD ; ; LIMIT lower limit of CASE range (if source < limit, CASE falls ; through). Default is #0. ; ; NMODE Mode for maximum argument of CASE (default is S^#). ; ;- .MACRO CASE,SRC,DISPLIST,TYPE=W,LIMIT=#0,NMODE=S^#,?BASE,?MAX CASE'TYPE SRC,LIMIT,NMODE'</2>-1 BASE: .IRP EP, .SIGNED_WORD EP-BASE .ENDR MAX: .ENDM CASE ;+ ERROR.BUGCHK ; ; ERROR.BUGCHK {bugchk,success} {,type=STOP} ; ; Tests for success following a system or user routine call that returns ; a condition code in R0. If an error occurred, LIB$STOP or LIB$SIGNAL ; are called to signal a "bugcheck" and stop the process. ; ; bugchk label for bugcheck routine call. If a label is given for ; this parameter, either it must be a local label or labels ; must be given for both the bugchk and success parameters! ; ; success success label (default to internal local label). ; ; type either STOP (default) for LIB$STOP or SIGNAL for LIB$SIGNAL. ; ;- .MACRO ERROR.BUGCHK bugchk,?success,type=STOP BLBS R0,success ;Was routine call successful? .IF NOT_BLANK bugchk ;Label for bugcheck call? bugchk: ;Yes, define the label .ENDC ;bugchk<>BLANK PUSHL R0 ;No, put status onto stack CALLS #1,G^LIB$'type ;Call signalling (and STOP) routine success: ;Success from routine .ENDM ERROR.BUGCHK ;+ ERROR.CONT ; ; ERROR.CONT success {,error} ; ; Tests for success following a system or user routine call that returns ; a condition code in R0 (the low bit of R0 is 1 for success and ; information completion codes). ; ; success success label to continue processing at ; ; error if specified, this becomes the label at the start of the ; error processing code following the macro call. ; ;- .MACRO ERROR.CONT success,error BLBS R0,success ;Was routine call successful? .IF NOT_BLANK error ;Error argument specified? error: ;Yes, label start of error code .ENDC ;error<>BLANK .ENDM ERROR.CONT ;+ ERROR.EXIT ; ; ERROR.EXIT {error} {,success} {,exit=RET} ; ; Tests for success following a system or user routine call that ; returns a condition code in R0. If an error label is specified, a ; branch to it (byte-displacment) will be taken if the low bit of R0 is ; zero. If the error parameter is not given, then a skip over an error ; exit will be made if the low bit of R0 is one (success/informational) ; where the error exit instruction (either RET or RSB) is given by the ; exit parameter (default is RET). ; ; error if specified, a BLBC (branch-on-low-bit-clear) on R0 is ; generated with this as the destination address. ; ; success success label (default to internal local label). ; ; exit if error not specified, then this provides the means for ; exiting the routine on an error. Default is RET. ; ;- .MACRO ERROR.EXIT error,?success,exit=RET .IF BLANK error ;Was an error address specified? BLBS R0,success ;Was routine call successful? exit ;No, exit with error code in R0 success: ;Success from routine .IF_FALSE ;Yes BLBC R0,error ;Was routine successful? ;Jumped to error code if not. .ENDC ;error=BLANK .ENDM ERROR.EXIT ;+ POPREG ; ; POPREG regnum ; ; POPREG pops a longword off the top of the stack into a general register. ; For registers R6-R14, the instruction "MOVL (SP)+,Rn" is used to pop the ; value. For registers R0-R5, the shorter (by one byte) sequence of ; "POPR #^M" is used. ; ; regnum register number to which the longword on top of stack ; is to be restored ; ;- .MACRO POPREG regnum .NTYPE ..mode,regnum ;get addressing mode of argument .IF NOT_EQUAL <..mode&^XF0>-^X50 ;check for general register mode .ERROR ;regnum is not a general register address mode .MEXIT .ENDC ;..mode<>Rn .IF LESS_THAN ..mode&^XF-6 ;Check register number POPR #^M ;registers R0-R5 .IF_FALSE MOVL (SP)+,regnum ;registers R6-R14 .ENDC ;..mode=R0 to R5 .ENDM POPREG ;+ TRANSFER_VECTOR ; ; TRANSFER_VECTOR entry {,JUMP=BRW} ; ; This macro generates a transfer vector for a shareable image. ; ; entry name of routine entry point (must be defined by .ENTRY). ; ; jump means by which control will be transferred to routine. ; Default is BRW, alternative is JMP. ;- .MACRO TRANSFER_VECTOR entry,jump=BRW .ALIGN QUAD ;Align on a quadword .TRANSFER entry ;Entry point (declared as .ENTRY) .MASK entry ;Routine register save mask jump entry+2 ;Skip over routine's entry mask .ENDM TRANSFER_VECTOR