Use this general macro, with the CM0ND macro to scan an input message for
keyword commands. The CM0PR macro is passed a pointer to a table of
expected keywords generated by CM0ND and a pointer to the input message to
scan. The CM0PR macro scans the input message for the presence of one
of the keywords. This macro skips insignificant characters:
blank, comma (,), right parenthesis ()), hyphen (-), and equal sign
(=).
Format
- label
- A symbolic name can be assigned to the macro statement.
- LIST
- This parameter specifies the pointer to the table of expected keywords
generated by CM0ND. The valid inputs are:
- label1
- A symbolic address of the table.
- (Rx)
- A general register (other than R0 and R15) containing the address of the
table.
- Note:
- The LIST parameter has no defaults.
- DATA
- This parameter specifies the pointer to the input message being
scanned. The valid inputs are:
- (Rx)
- A general register (other than R0, R14 and R15) containing the address of
the input message being scanned.
- Note:
- If the DATA parameter is omitted, R1 is assumed to be the pointer to the
input message block.
- RETURN
- This specifies the address of a branch vector list to be given control
upon completion of the macro. The first branch vector in the list is
always given control if no keyword is found in the input message or
end-of-message is detected. If the first keyword in the table is found
in the input message, then control is given to the second branch
vector. If the second keyword in the table is found in the input
message, then control is given to the third branch vector, and so on.
The valid inputs are:
- (Rx)
- This is a general register (other than R0, R14 and R15) containing the
address of the branch vector list.
- (NO)
- The branch vector list is assumed to be coded at the next sequential
instruction.
- Note:
- If the RETURN parameter is omitted, the (NO) option is assumed.
- BV
- This specifies the register that is to contain the branch vector at the
completion of the macro. The valid inputs are:
- (Rx)
- This is a general register that contains the branch vector resulting from
the scan. If this parameter is coded, control will be either given to
the NSI or to the address specified in the RETURN parameter. It will be
the responsibility of the calling program to perform the appropriate indexing
into a branch vector list according to the contents of Rx.
- (NO)
- No register is to be loaded with the branch vector.
- Note:
- If the BV parameter is omitted, the (NO) option is assumed.
Entry Requirements
- The LIST parameter must be coded to point to a keyword table generated by
the CM0ND macro.
- A branch vector table containing N+1 branch instructions, where N is the
number of entries in the keyword table. See the examples.
Return Conditions
- If the BV parameter is coded with the (Rx) option, Rx will be loaded with
the branch vector resulting from the scan. Control will then be given
to either the NSI or to the address specified in the RETURN parameter.
It will be the responsibility of the calling program to perform the
appropriate indexing into a branch vector list according to the contents of
Rx.
- If the BV parameter is coded with the (NO) option, or is omitted
altogether, the macro will perform the appropriate indexing into a branch
vector list according to the RETURN parameter.
- If the Return parameter is coded with the (Rx) option, control is
transferred into the branch vector list addressed by (Rx). Otherwise,
control is transferred into the branch vector list starting at the NSI.
- The register specified by the DATA parameter will point immediately past
the recognized keyword or will remain unchanged if no keyword is found.
- The contents of R0, R14 and R15 are unknown.
- All other registers remain unchanged across this macro call.
Programming Considerations
- This macro can be executed on any I-stream.
- This macro may be invoked by both C-type as well as E-type
programs.
- This macro expands inline to a variable number of bytes, depending on the
parameters coded.
- Since the macro expansion is so large, the macro should only be coded once
within any given program.
- If there is a need to invoke the macro multiple times to scan different
keyword tables, CM0PR could be placed in a subroutine and the various macro
parameters could be used to achieve the various desired scans. See the
examples.
Examples
In all the examples the following assumptions will be made:
- R3 has been initialized to point to the start of an input message.
- Two keyword tables exist:
TABLE1 CM0ND DISPLAY,3,START,,DEFINE,3,LOCATE,3
TABLE2 CM0ND STATUS,3,RESOURCES,3,BUFFER,3
Using the LIST parameter with the label option:
CM0PR LIST=TABLE1,DATA=(R3)
B ERRORTN BV for no match or EOM condition
B DISPRTN BV for DISplay keyword
B STRTRTN BV for START keyword
B DEFNRTN BV for DEFine keyword
B LOCTRTN BV for LOCate keyword
Using the LIST parameter with the (Rx) option:
LA R2,TABLE2 Get address of TABLE2
CM0PR LIST=(R2),DATA=(R3)
B ERRORTN BV for no match or EOM condition
B STATRTN BV for STAtus keyword
B RESCRTN BV for RESources keyword
B BUFFRTN BV for BUFfer keyword
Using the CM0PR macro in a subroutine and the RETURN parameter:
LA R2,TABLE1 Get address of TABLE1
BAS R7,SCANRTN Go scan for keywords from TABLE1
B ERRORTN BV for no match or EOM condition
B DISPRTN BV for DISplay keyword
B STRTRTN BV for START keyword
B DEFNRTN BV for DEFine keyword
B LOCTRTN BV for LOCate keyword
.
.
LA R2,TABLE2 Get address of TABLE2
BAS R7,SCANRTN Go scan for keywords from TABLE2
B ERRORTN BV for no match or EOM condition
B STATRTN BV for STAtus keyword
B RESCRTN BV for RESources keyword
B BUFFRTN BV for BUFfer keyword
.
.
SCANRTN DS 0H
CM0PR LIST=(R2),DATA=(R3),RETURN=(R7)
Calling the CM0PR macro in PGMY from PGMX and the BV parameter:
BEGIN NAME=PGMX
.
.
LA R2,TBLINDX2 Set table index for TABLE2
ENTRC PGMY Go scan for keywords from TABLE1
B *+4(R1) Branch using the branch vector
B ERRORTN BV for no match or EOM condition
B STATRTN BV for STAtus keyword
B RESCRTN BV for RESources keyword
B BUFFRTN BV for BUFfer keyword
.
.
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
BEGIN NAME=PGMY
.
initialize R2 to point to correct keyword
table according to the supplied table index.
.
CM0PR LIST=(R2),DATA=(R3),BV=(R1)
BACKC Return to calling program