On 5/1/2013 9:27 AM, Etienne Thijsse wrote:
Hi all,

I am trying to call an assembler function from C:

C-code (bla.c):

#pragma linkage(BLA,OS)
main()
{
     BLA();
     printf("No crash.\n");
}

Assembler code (bla1.s):

BLA     CSECT
BLA     MODE  ANY

            SAVE   (14,12)
            BALR    3,0
            USING  *,3
            ST        13,SAVE+4      <<<<< crashes here

*         todo: add useful code here

            L           15,=X'01'
            L           13,SAVE+4
            RETURN (14,12),RC=(15)

SAVE   DS       18F
            END

So the only code in this assembler source is the "standard linkage" stuff,
which I got from the "MVS Assembler Language" book.

Ummm. Which book is that? There is the MVS Assembler Services Guide
and the MVS Assembler Services Reference (2 volumes), but I don't
see 'MVS Assembler Language' as a doc.

In any case, none of the examples in these books quite match
what you show.

Perhaps your cut and paste is off, but at the least
'MODE' should be 'AMODE'; it's pretty unusual, but not wrong,
to choose reg. 3 for your base. A more traditional version
might be:

BLA     CSECT
BLA     AMODE  ANY
        SAVE   (14,12)
        LR     12,15
        USING  BLA,12
        ST     13,SAVE+4      <<<<< crashes here

*         todo: add useful code here

        L      15,=X'01' <== not sure what you intend to happen here
                         <== perhaps better:
            LA 15,1      <== would give a return code of '1'
        L      13,SAVE+4
        RETURN (14,12),RC=(15)
SAVE    DS       18F
        END

Still, I don't see any clear reason for your abend.



I compiled and linked this under OpenMVS like this:

   cc bla.c bla1.s

which gives me an executable 'a.out' in the HFS.

Running this under OpenMVS  crashes in the "ST        13,SAVE+4"  line, SC04. 
If I comment out that line and the corresponding L13,SAVE+4 line, it does not crash 
anymore.
I don't understand this... This ST line is part of the standard linkage 
'protocol'; the area where the ST stores is declared in the SAVE DS 18F line at 
the bottom --- Why does this crash?

What is weirder still is that I can copy a.out to a PDSE member, and submit it 
with some JCL that has CEE.SCEELIB in its STEPLIB; this does not crash, without 
SCEELIB it also crashes.
Adding CEE.SCEELIB to the STEPLIB environment variable in OpenMVS however does 
not help, it keeps crashing, SC04.

Anyone have an idea?

Thanks,
Etienne


1. What version of z/OS are you running?

2. The z/OS UNIX Command Reference doc points out that 'cc' command
   "is fully supported for compatibility with older UNIX systems.
   However, it is recommended that the c89 command be used instead"

3. The default binder option is, essentially, NORENT, so the other
   suggestion of an extra step to bind this way is not necessary

You might check out the values in the environment variables that
influence how the c89 command works.


--

Kind regards,

-Steve Comstock
The Trainer's Friend, Inc.

303-355-2752
http://www.trainersfriend.com

* To get a good Return on your Investment, first make an investment!
  + Training your people is an excellent investment

* Try our tool for calculating your Return On Investment
    for training dollars at
  http://www.trainersfriend.com/ROI/roi.html

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to