Page 1 of 1

Using LE, Assembler calling C++

PostPosted: Wed Jun 26, 2013 11:14 am
by micks128
Hi all, I'm quite new to assembler so please be gentle. I'm using the example from the LE manual.

http://publib.boulder.ibm.com/infocente ... 26_3_7_2_4

Using the pre-initialization service CEEPIPI to call a small C++ program. The example as shown worked fine.

Next I tried to pass a parameter using the parm_ptr of the call_sub function

parm_ptr (input)
A parameter list pointer or 0 (zero) that is placed in register
1 when the routine is executed.
C and C++ users need
to follow the subroutine linkage convention for C/C++ — assembler
ILC applications, as described in z/OS XL C/C++ Programming Guide.

Here is the parameter list I am passing

ADDR_BLK DC   A(FMTSTR)                parameter address block with..   
         DC   A(X'80000000'+INTVAL)    ..high bit on the last address   
FMTSTR   DC   C'Sample formatting string'                               
         DC   C' which includes an int -- %d --'                       
         DC   AL1(NEWLINE,NEWLINE)                                     
         DC   C'and two newline characters'                             
         DC   AL1(NULL)                                                 
*                                                                       
INTVAL   DC   F'222'            The integer value displayed             
*                                                                       
NULL     EQU  X'00'             C NULL character                       
NEWLINE  EQU  X'15'             C \n character                         

I followed the linkage instructions for a C++ program
I used compiler option PLIST(OS)
I made the C++ function export "OS"

Here is my C++ code

#pragma linkage(HLLPIPI, FETCHABLE)

extern "OS" {

int HLLPIPI ()
{
 printf ( "C subroutine beginning\n" );
 printf ( "Called using LE PreInit call\n" );
 printf ( "Subroutine interface.\n" );
 printf ( "C subroutine returns to caller\n" );
 printf ( "Parameter is %d\n", (int)__R1 );
 printf ( "Parameter is %p\n", __osplist[0] );
 return 0;
}

}


When I tried to run I always get 0 for the value of R1 where I am expecting a pointer to my paramter list. Has anyone else tried this and has success. Can you see what I am missing?

Code'd

Re: Using LE, Assembler calling C++

PostPosted: Thu Jul 11, 2013 4:34 pm
by NicC
Any update on this?