I have code on windows that I use to display assembler listing. I down load
the SYSADATA and have a DLL that does reads and does various other
functions. Since I have a need for the same functionality on z/os I figured
I would use the same code.

I knew there would be differences but I figured I could use #ifdef __MVS__
for that.  Originally I thought of LE but found its way to inflexible. My
code is amode 31 

I have a number of functions 1) openfile - opens the sysadata and has
various pointers to various sections. There is a certain order to the
sysadata 20 external symbols precede 30 source code 36 machine code
eventually follow 30

My code would store these in dataspace.

Since my Main Program OPENFILE is reading the  SYSADATA I have tried to tell
the compiler that is main 

With     #pragma (main, "cfunction")  and then having the following for the
program prototype as such int cfunction(int aletd, char *filename)
The only difference I found between having this #pragma (main) is that that
having a main generates STORAGE OBTAIN for the DSA
This code was generated with the pragma main

Label @@BGN@1 is the beginning of the compiler generated code

@@BGN@1  DS    0H              
          AIF   (NOT &CCN_SASIG)
          LLILH 11,X'C6F7'      
          OILL  11,X'E2C1'      
          ST    11,4(,13)       
 .@@NOSIG1 ANOP                 
          AIF   (&CCN_NAB_STORED
          LA    11,760          
          ALR   11,13           
          ST    11,#NAB_1-@@AUTO
          MVHI  #NAB_1-@@AUTO@1(
 .@@NONAB1 ANOP                 
          USING @@AUTO@1,13     
          LARL  3,@@LIT@1       
          LAE   3,0(3)          
          USING @@LIT@1,3       
          ST    0,#WSA_1        <=== store of 0

without #pragma main
@@BGN@1  DS    0H              
          AIF   (NOT &CCN_SASIG)
          LLILH 11,X'C6F7'      
          OILL  11,X'E2C1'      
          ST    11,4(,13)       
 .@@NOSIG1 ANOP                 
          AIF   (&CCN_NAB_STORED
          LA    11,760          
          ALR   11,13           
          ST    11,#NAB_1-@@AUTO
          MVHI  #NAB_1-@@AUTO@1(
 .@@NONAB1 ANOP                 
          USING @@AUTO@1,13     
          LARL  3,@@LIT@1       
          LAE   3,0(3)          
          USING @@LIT@1,3       
          ST    0,#WSA_1    <== 


Here are my compiler options

//STEP0110 EXEC PGM=CCNDRVR,REGION=0M,

// PARM='/SOURCE,METAL,NOSEARCH,SEARCH(/usr/include/metal/),GENASM,ASM,*

//             SHOWINC,ARMODE,RENT'                                    

The truth is having prolog gives me the ability to make it look more like a
windows DLL as it has a DLLMAIN. By having a setb symbol I can tell it that
this the main entry point get storage for the entires in the DLL and set the
right NAB pointer for R13

The only other pragma (instruction to the compiler ) I have in my program is
for the prolog     

thanks

 










            
    

-----Original Message-----
From: IBM Mainframe Discussion List <IBM-MAIN@LISTSERV.UA.EDU> On Behalf Of
Peter Relson
Sent: Sunday, January 26, 2020 9:24 AM
To: IBM-MAIN@LISTSERV.UA.EDU
Subject: Re: Prolog code of Metal C program (register 0)

<snip>
I have been getting S0C4 on initialization to my Metal C program </snip>

Once again, you have not provided enough information for most of the readers
of your post to help you.
Not every "Prolog code of Metal C program" has such a store of register 0. 
This is easily demonstrated.
Thus perhaps you in some way "told" the compiler that your linkage was such
that it made sense to save register 0 into a variable called #WSA_1.
And the fix will be not to do that.

By the way, LOAD and BASR will not work if the target is AMODE 64.
LOAD returns a value in (64-bit) register 0 that is suitable for use by
BASSM.
That happens to be OK for use by BASR in AMODEs 24 and 31 but not AMODE 64.
Thus one approach that works regardless of AMODE is
  LGR   15,0
  BASSM 14,15

If you know that your target is AMODE 24/31 then LR and BASSM (or BASR) is
OK.

Of course if you do have an AMODE 64 target, you need to make sure that you
set up the interface according to its requirements, whatever they happen to
be. Some AMODE 64 targets might be sensitive to "called by AMODE 24/31" and
some might not; some might require 8-byte register 1, with a parameter list
of 8-byte pointers.

Peter Relson
z/OS Core Technology Design


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

----------------------------------------------------------------------
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