Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

IBM-MAIN - S0C4 beim Aufruf eines Moduls via CEEPIPI

Subject:

Re: S0C4 when passing Parameter to C++ program from ASM (CEEPIPI)

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU>

Date:

2015.03.03 18:30:00


Because nobody else has a solution so far, I'll try to give some
advice, although I don't see the problem, too. Don't know much about CEEPIPI.

First:

#pragma map(SDKREAD,"SDKREAD")

is not needed. #pragma map is meant to rename longer names to the classical
linker, which allows only 8 char names, all upper case. But SDKREAD is a perfect
name for the classical linker, so you don't need this #pragma map.

Then:

I don't think -extern "OS"- is needed. The funktion SDKREAD is extern, anyway.

I would write the function like this:

int SDKREAD (char *PRINTLine)
{
   printf ("SDKREAD Entered \n"); // This executed successfully
   //function will be called from assembler
   printf ("%s\n", PRINTLine);
   return 0;
}

Does "This executed successfully" mean, that you see the message "SDKREAD
Entered" in the output, that is, that the C function has been entered
successfully? If so, there is no problem with CEEPIPI etc., only a problem with
the parm.

If written like this, C expects an address list pointed to by register 1, where
the first address is a pointer pointing to a null-terminated char.

Note: I modified the printf, because in your variant, the PRINTLine will be
scanned for % signs, to see, if more parameters have to be read. With my
solution, there is only one string parameter, PRINTLine.

I guess: the way you pass the parm using the CEEPIPI interface is wrong in some
manner.

Normal call from ASSEMBLER (using static linkage) would be

    CALL  SDKREAD,(PRINTLINE)

or

    LA    R1,ADRLIST
    CALL  SDKREAD
...
ADRLIST   DC A(PRINTLINE)

BTW: this is C, not C++

(which makes a big difference, at least to me).

Kind regards

Bernd




Am 03.03.2015 um 15:33 schrieb D.L.:
> This has been a frustrating adventure. I hope this is easy for someone who has
> already done this. I need to call a C++ program from an ASM program and pass it
> parameters. I plan to use CEEPIPI to do the call because it is documented as
> being efficient(as documented in the “LE Programming Guideö) but when tried
> it abends on an S0C4 when attempting to access the parameter. Note: The call was
> successful but it failed when accessing the passed parameter. So I tried the
> example exactly as coded in the "C grammer's Guide". I could not get it to link
> properly so I renamed some modules and changed the assembler program to issue a
> load and finally received an S0C7! In all cases the CEEDUMP was pretty much
> useless and it is not abending in my code.
>
> EDIT       TSSDON.CSOURCE(SDKMAIN) - 01.15
> Command ===>
> ****** ***************************** Top of Data ******
> 000001
> 000002 // this program will print what is passed. It is
> 000003
> 000004 #include <stdio.h>
> 000005 #include <stdlib.h>
> 000006 #include <string>
> 000007
> 000008 #pragma map(SDKREAD,"SDKREAD") (I do not know what this does)
> 000009
> 000010 extern "OS" int SDKREAD(char PRINTLine[121])
> 000011   {printf("SDKREAD Entered \n"); ? This executed successfully
> 000012   //function will be called from assembler
> 000013   printf(PRINTLine,"\n");
> 000014   return 0;
> 000015   }
>
> The meat of the ASM calling program:
>           Start of program
>           LOAD  EP=CEEPIPI         LOAD CEEPIPI ROUTINE DYNAMICALLY
>           ST    R0,PPRTNPTR        SAVE THE ADDR OF CEEPIPI ROUTINE
> *C  INITIALIZE AN LE PIPI SUBROUTINE ENVIRONMENT.
> *
>           LA    R5,PPTJL           GET ADDRESS OF PIPI TAJLE
>           ST    R5,@CEXPTJL        CEEXPTJL-ADDR -> PIPI TAJLE
>           L     R15,PPRTNPTR       GET ADDRESS OF CEEPIPI ROUTINE
> *                                 INVOKE CEEPIPI ROUTINE
> INITPPI  CALL  (15),(INITSUB,@CEXPTJL,@SRVRTNS,RUNTMOPT,TOKEN)
> *C  CALL SDKREAD
> *        CALL  (15),(CALLSUB,SDKREADI,TOKEN,SDKBUFA,
> *              SUBRETC,SUBRSNC,SUBFBC)   INVOKE CEEPIPI ROUTINE
>           LA    R1,PRINTA
>           ST    R1,SDKREADM
>           LA    R1,SDKREADP
>           L     R15,PPRTNPTR       GET ADDRESS OF CEEPIPI ROUTINE
>           BASR  R14,R15
>         ** End of program **
>
> INITSUB  DC    F'3'            FUNCTION CODE TO INITIALIZE FOR SUBR
> @CEXPTJL DC    A(PPTJL)        ADDRESS OF PIPI TAJLE
> @SRVRTNS DC    A(0)            ADDR OF SERVICE-RTNS VECTOR, 0 = NONE
> RUNTMOPT DC    CL255' '        FIXED LENGTH STRING OF RUNTIME OPTNS
> TOKEN    DS    F                  UNIQUE VALUE RETURNED (OUTPUT)
> CALLSUB  DC    F'4'               FUNCTION CODE TO CALL SUBROUTINE
> PTBINDEX DS    F                  THE ROW NUMBER OF PIPI TAJLE ENTRY
> PARM     DS    A                  PARAMETER TO PASS TO MEASTRMN
> SUBRETC  DS    F                  SUBROUTINE RETURN CODE (OUTPUT)
> SUBRSNC  DS    F                  SUBROUTINE REASON CODE (OUTPUT)
> SUBFBC   DS    3F                 SUBROUTINE FEEDBACK TOKEN (OUTPUT)
> *
> * ====================================================================
> * PIPI TAJLE.
> * ====================================================================
> PPTJL    CEEXPIT  ,               PIPI TAJLE WITH INDEX
> PPT      DS    0A
>           CEEXPITY SDKPUT,0
>           CEEXPITY SDKREQ,0
>           CEEXPITY SDKREAD,0
>           CEEXPITS                 END OF PIPI TAJLE
> SDKPUTI  DC    F'0'              ROW NUMBER OF PIPI TAJLE FOR SDKPUT
> SDKREQI  DC    F'1'              ROW NUMBER OF PIPI TAJLE FOR SDKREQ
> SDKREADI DC    F'2'             ROW NUMBER OF PIPI TAJLE FOR SDKREAD
>
> SDKREADP DS    0A          PARAMETER LIST TO CALL SDKREAD
>           DC    A(CALLSUB)
>           DC    A(SDKREADI)
>           DC    A(TOKEN)
> SDKREADM DC    A(0)        MESSAGE TO READ
>           DC    A(SUBRETC)
>           DC    A(SUBRSNC)
> SDKREADE DC    A(SUBFBC)
> PRINTA   DC    A(X'80000000'+PRINT)
> PRINT    DC    CL121'PRINT THIS LINE'
>           DC    X'00'
>
> I've been working on this for days now, so any help will be greatly appreciated.
>

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie