Using LE, Assembler calling C++

High Level Assembler(HLASM) for MVS & VM & VSE

Using LE, Assembler calling C++

Postby micks128 » Wed Jun 26, 2013 11:14 am

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

Code: Select all
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

Code: Select all
#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
micks128
 
Posts: 1
Joined: Wed Jun 26, 2013 10:56 am

Re: Using LE, Assembler calling C++

Postby NicC » Thu Jul 11, 2013 4:34 pm

Any update on this?
The problem I have is that people can explain things quickly but I can only comprehend slowly.
Regards
Nic
NicC
Global moderator
 
Posts: 2218
Joined: Sun Jul 04, 2010 12:13 am
Location: Down on the pig farm


Return to Assembler

 


  • Related topics
    Replies
    Views
    Last post