C/C++

C/C++

C/C++

Your one-stop destination to learn and collaborate about the latest innovations in IBM C/C++ for z/OS compilers to develop high-performing C/C++ applications and system programs on z/OS while maximizing hardware use and improving application performance.

 View Only
  • 1.  Changing AMODE in Metal C

    Posted Fri January 30, 2015 05:56 PM

    Hi,

    Metal C documentation implies that when calling a AMODE31 function from an AMODE64 function, that the generated code will first switch from AMODE64 to AMODE31, and then issue the call.

    My question is: Does the generated code preserve the High Halves of the 64 bit registers?

    Or am I expected to do so in the C code at entry, or in the 31 PROLOG macro code (and restore them in the 31bit EPILOG)?

    Frank

    Frank_O_Myers@IBM


  • 2.  Re: Changing AMODE in Metal C

    Posted Thu March 05, 2015 11:33 AM

    Hello, Frank,

    Here is a quick, simple example; just to make sure I understand your question:

    >amode64.c  compile amode64

    long long foo (long long) __attribute__((amode31));

    int main () {

            long long a = 2147483647;
            if (a = foo(a)) {
                    return 55;
            } else {
                    return 66;
            }
    }

     

    >amode64_32.c

    long long foo (long long a) {
            long long b;
            __asm(" LLGF %0,%1\n":"=r"(b):"r"(a));
            return b;
    }

     

    xlc -qMETAL -S -q64 amode64.c

    xlc -qMETAL -S amode64_32.c

    Does this example look like the kind of thing you want to do?  If yes, then compiler in the "31 PROLOG" and "31 bit EPILOG" of amode64_32.s saves and restores the high halves of those registers that it clobbers via STMH and LMH instructions respectively.

    Does that answer your question?

    I'd like to add that if you are calling a function that is not compiled with MetalC, for example an assembler program, then you are responsible for preserving the high halves of the registers.

    Please, let me know if you have more questions and/or comments.

    Thanks.

    Visda