IBM Z and LinuxONE Languages

Languages

Languages

Broad range of supported development languages and tools allows to transform software delivery practices.

 View Only
  • 1.  Metal C - routine exit linkage question

    Posted Thu January 16, 2020 09:54 AM
    Since I'm moaning about the entry linkage, I figured I shouldn't ignore the exit linkage and give it some time, as well.  Are there restrictions that I haven't read that require that the save area passed to a Metal C routine (or in general when using a F7SA) that the storage be in current primary?

    Here's what I'm seeing for the exit linkage for the routine that I reference in this message (the comments are mine):
      
    LG    13,128(,13)    -- chain back to caller's save area
    L     1,208(,13)     -- **** obtain saved ASC mode (could be AR)
    SAC   0(1)           -- back to caller's ASC mode
    LAM   13,13,204(13)  -- **** restore AR13        
    LG    14,8(,13)      -- get return address from caller's save area
    LMG   1,12,32(13)    -- restore caller's grande registers
    LAM   1,12,156(13)   -- restore caller's access registers
    BR    14             -- return to caller
    A couple of thoughts:
    1. Remember that "this" routine is running in AR ASC mode (the entry linkage does a SAC 512 after storing the caller's AR13 in the caller's save area).
    2. The first LG will chain back from "this" routine's SA to the caller's, but the instructions that are tagged with "****" will be using the current content of AR13, referring "this" routine's ALET for the DSA.  Wouldn't it be only "favorably coincidental" that the caller's AR13 happens to be the same as "this" AR13?
    Of course, everything works correctly if AR13 is always the same...

    Thanks,
    Scott​



  • 2.  RE: Metal C - routine exit linkage question

    Posted Fri January 17, 2020 03:49 AM
    Hi Scott,

    I didn't find the restriction that the save area should be in primary.

    The example you referred may be only effective under specific conditions, it might have been optimized by Compiler according to the conditions.

    The example in 'If changing ARs without using the linkage stack' seems a complete one, for example, it contains the steps to request and release storage for 'my savearea'. And its steps that fetch caller's AR13 seems stable.
    https://www.ibm.com/support/knowledgecenter/en/SSLTBW_2.4.0/com.ibm.zos.v2r4.ieaa600/f7saxmp.htm

    If referring to above example, it should be combined with 'additional instructions' in 'Metal C AR-mode programming support'.

    ------------------------------
    He Huang
    ------------------------------