To paraphrase the Great and Powerful Oz, "Pay no attention to that man behind 
the macro."

I had made a bunch of clean-up to this macro, renaming operands to be more 
meaningful, and mistakenly sent out a partially-updated copy. A fully-updated 
copy is attached. I cleaned up the MEXIT and &A errors and also added a few 
comments indicating that general register 0 shouldn't be used for the pointer 
or length, and dropped the fifth operand off the RISBGT instruction (since it's 
optional and defaults to zero). 

        MACRO
&LABEL   WIF   &P=1,&L=,&C=,&S=0,&OK=,&NFG=
.*
.* Will It Fit?
.*
.* Given the following:
.*   1.  Register "P" pointing to the next available location in an
.*       integral buffer (i.e., the size and alignment are a power of
.*       two);
.*   2.  Register "L" containing the length of a prospective object to
.*       be added to the buffer; and
.*   3.  Characteristic C, where C represents the integral boundary as
.*       a power of two;
.*  Will the prospective object fit within the buffer?
.*
.*  Operands:
.*   P:    Starting address; default is general register 1.
.*   L:    Length of object in a general register; no default.
.*   C:    Characteristic (i.e., power of two) representing the
.*         integral boundary (e.g., C=8 means a 256-byte boundary).
.*   S:    Scratch register; default is general register 0.
.*   OK:   Branch location if the object fits; no default.
.*   NFG:  Branch location if the object does not fit; no default.
.*
.* A PSW condittion code of zero indicates the object fits, and may be
.* used in place of the OK and/or NFG operands.
.*
.* Note: For proper operation, both P and L should designate a general
.* register other than 0.
.*
         AIF   (&C GT 64).BAD_C
&LABEL   LAY   &S,-1(&L,&P)       Point at last prospective byte.
         RXSBGT &S,&P,0,63-&C     Carry past boundary?
         AIF   ('&OK' EQ '').SKIP_OK
         JZ    &OK                No; prospective object fits.
.SKIP_OK ANOP
         AIF   ('&NFG' EQ '').SKIP_NFG
         JNZ   &NFG               Yes; prospective object doesn't fit.
.SKIP_NFG MEXIT
.BAD_C   MNOTE 8,'C must be between 0 and 63.'
         MEND

Reply via email to