;++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 ; V02.00 10-Aug-83 FJN Eliminated ERROR. macros ... ; ;+ BERR ; ; BERR error ; ; Branches on an error following a system or user routine call that ; returns a condition code in R0 (the low bit of R0 is 0 for error, ; severe error and warning completion codes). ; ; error label to branch to if the R0 completion code indicates ; an error (of any class). ;- .MACRO BERR error BLBC R0,error ;Branch if previous call failed .ENDM BERR ;+ BNERR ; ; BNERR success ; ; Branches on 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 informational completion codes). ; ; success label to branch to if the R0 completion code indicates ; success. ;- .MACRO BNERR success BLBS R0,success ;Branch if previous call successful .ENDM BNERR ;+ 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 ;+ 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 ;+ _SIGNAL ; ; _SIGNAL {name} ; ; Signal a condition by calling LIB$SIGNAL. If no argument is given, ; the condition code is assumed to be in R0. Otherwise the argument ; is taken to be the name of the constant condition code. ;- .MACRO _SIGNAL name .IF BLANK name PUSHL R0 ;Signal code is in R0 .IF_FALSE PUSHL #name ;Signal code is named constant .ENDC ;name??BLANK CALLS #1,G^LIB$SIGNAL ;Signal the condition .ENDM _SIGNAL ;+ _STOP ; ; _STOP {name} ; ; Signal a condition and stop by calling LIB$STOP. If no argument is ; given, the condition code is assumed to be in R0. Otherwise the ; argument is taken to be the name of the constant condition code. ;- .MACRO _STOP name .IF BLANK name PUSHL R0 ;Signal code is in R0 .IF_FALSE PUSHL #name ;Signal code is named constant .ENDC ;name??BLANK CALLS #1,G^LIB$STOP ;Signal the condition and stop .ENDM _STOP ;+ _TSTSTOP ; ; _TSTSTOP {success} ; ; Test for success condition code in R0. If condition is not success ; (or informational), then signal the condition and stop by calling ; LIB$STOP. If no argument is specified, success falls out the bottom ; of this macro. If the argument is given, then detection of success ; causes a branch to the specified label (given as the argument). ;- .MACRO _TSTSTOP success,?intsuc .IF BLANK success BNER intsuc ;Skip on if success returned _STOP ;Stop by signalling the error intsuc: .IF_FALSE BNER success ;Skip on if success returned _STOP ;Stop by signalling the error .ENDC ;success??BLANK .ENDM _TSTSTOP