There is a section in the P/G dealing with calling C from assembler.

It makes a difference whether the assembler code is LE-enabled or not, and if 
not, whether you want to build the LE environment yourself or let C do it by 
default. Also whether the C is XPLINK or not.

Charles

-----Original Message-----
From: IBM Mainframe Discussion List [mailto:[email protected]] On Behalf 
Of Pierre Fichaud
Sent: Tuesday, May 10, 2016 1:58 PM
To: [email protected]
Subject: Assembler ATTACHing C

I have an assembler program that creates a sub-task using ATTACHX. 
It sets up a parameter list, pointed to by R01, for the sub-task.

The C code is a main program and so has main (int argc, char *argv[]) It has  
#pragma environment(main) The program is compiled with 
SS,LIS,SO,OPT,RENT,LO,NOSTART,DEF(USE_SPC)

When I attempt to get at argc and argv, R01 does not point to the right place. 
So I forced an S0C4 at the very beginning of the C program and got an SVC dump.

The system trace table clearly shows the ATTACH SVC entry with R01 pointing to 
the correct place.
TCBFSA of the ATTACHed task points to a save area and the value of R01 is 
correct.

The C sub-task code has prolog code that is called with a BALR  R15,R15 and 
this must be modifying R01.

I'm wondering if someone has done this before and got it to work.
This C code has to be a sub-task and there is too much C code to rewrite.

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to