Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved


Chapter 10 Accessing External Routines : Observing Standard Conventions

Observing Standard Conventions
TIBCO Object Service Broker executes as an assembler environment; you must write and link your program so it can be called by an assembler program using standard conventions as outlined below.
Information Available to an External Routine
When an external routine receives control, the following information is available:
If the routine is a function, the first address points to the area for the returned value.
Use of the AMODE and RMODE Attributes
TIBCO Object Service Broker uses the AMODE and RMODE attributes of the load module (for an external routine) to determine:
When control is passed back to TIBCO Object Service Broker, you can access a return code in register 15 by using the RETURN_CODE tool.
Storage Requirements
This table shows how TIBCO Object Service Broker syntax is mapped to assembler storage requirements.

Assembler Storage Requirements
CLn+2

1
TIBCO Object Service Broker supports floating point, 16 bytes long, which is not supported in COBOL and therefore cannot be used in COBOL subroutines.

2
An RD field consists of a four-byte non-exclusive binary length followed by the data.

Example Assembler Program
The following external routine returns the number of occurrences of a specified character in a given string. The routine requires three arguments: STRING, CHAR, and FOLD. It returns a value through COUNT. The routine and its arguments must be identified to TIBCO Object Service Broker as described in Identifying Your External Routine to TIBCO Object Service Broker.

 
***********************************************************************
*         CHRINSTR(STRING,CHAR,FOLD)                                  *
*                                                                     *
*         RETURNS THE NUMBER OF OCCURRENCES IN STRING OF THE SINGLE   *
*         CHARACTER CHAR;                                             *
*         IF FOLD IS 'Y' IGNORE CASE-SENSITIVITY;                     *
*
         SPACE 2
PARMLIST DSECT
RCOUNT   DS    A                       ADDRESS OF RETURNED COUNT
*                                      ... (C,P,4,0)
PSTRING  DS    A                       ADDRESS OF INPUT STRING
*                                      ... (S,V,256,0)
PCHAR    DS    A                       ADDRESS OF INPUT CHAR
*                                      ... (S,V,1,0)
PFOLD    DS    A                       ADDRESS OF INPUT FOLD
*                                      ... (S,C,1,0)
         SPACE 2
CHRINSTR AMODE 31                      EXECUTES IN 31-BIT ADDRESSING
CHRINSTR RMODE ANY                     RESIDES ANYWHERE
CHRINSTR CSECT
*
*        ESTABLISH ADDRESSABILITY
*
         USING CHRINSTR,R12
         USING PARMLIST,R11
         STM   R14,R12,12(R13)         SAVE CALLER'S REGISTERS
         LR    R12,R15                 CSECT BASE REGISTER
         LR    R11,R1                  ARGUMENT BASE REGISTER
*
*        LOAD THE INPUT STRING AND CHARACTER
*
         L     R2,PSTRING              POINT TO STRING ARGUMENT
         LH    R3,0(,R2)               LOAD LENGTH
         LA    R2,2(,R2)               SKIP PREFIX LENGTH
         XR    R4,R4                   RESET COUNTER
         LTR   R3,R3                   EMPTY STRING?
         BZ    RETURN                  YES, RETURN RESULT
         L     R5,PCHAR                POINT TO CHAR ARGUMENT
         LA    R5,2(,R5)               SKIP PREFIX LENGTH
*
*        PROCESS FOLD INDICATOR
*
         L     R6,PFOLD                POINT TO FOLD ARGUMENT
         CLI   0(R6),C'Y'              SHOULD WE FOLD?
         BNE   LOOP                    NO, CONTINUE
*
*        CODE TO IGNORE DIFFERENCE OF CASE IF FOLD IS 'Y' CAN BE PUT HERE
*
*        MAIN LOOP: PROCESS ONE CHARACTER AT A TIME
*
LOOP     DS    0H
         CLC   0(1,R2),0(R5)           CURRENT CHAR MATCH?
         BNE   NEXTCHAR                NO, CONTINUE
         LA    R4,1(,R4)               ELSE, INCREMENT COUNTER
NEXTCHAR DS    0H
         LA    R2,1(,R2)               ADVANCE TO NEXT CHARACTER
         BCT   R3,LOOP                 LOOP IF NOT END OF STRING
*
*        COPY RESULT TO RETURN AREA
*
RETURN   DS    0H
         L     R2,RCOUNT               POINT TO RESULT AREA
         CVD   R4,PRESULT              CONVERT RESULT TO DECIMAL
         ZAP   0(4,R2),PRESULT+4(4)    COPY TO RESULT AREA
         LM    R14,R12,12(R13)         RESTORE CALLER'S REGISTERS
         XR    R15,R15                 ZERO RETURN CODE
         BR    R14                     RETURN TO CALLER
*
*        DATA AREA
*
         DS    0D                      ALIGN ON DOUBLE-WORD BOUNDARY
PRESULT  DS    PL8                     AREA FOR CONVERSION
         LTORG ,
         COPY  REGEQU                  REGISTER DEFINITIONS
         END   CHRINSTR

 
See Also
TIBCO Object Service Broker Programming in Rules about TIBCO Object Service Broker syntax.
TIBCO Object Service Broker Shareable Tools about the tools.

Copyright © TIBCO Software Inc. All Rights Reserved
Copyright © TIBCO Software Inc. All Rights Reserved