On 11/12/21 3:04 PM, Peter Relson wrote:
I'd think that if you want decent code, you don't ask for no optimization.

I have the following C function with embedded ASM:

int asmFunct(void *asmEntryPoint, void *functParms) {

 int functRC;

 __asm( " L    15,%1          \n"
   " LR   1,%2          \n"
   " L    1,24(1)       \n"
   " BALR 14,15         \n"
   " ST   15,%0           "
   :"=m"(functRC):"m"(asmEntryPoint), "r"(functParms)
   :"r1","r14","r15");

 return 0;
}

When compiled with 5650ZOS V2.3 z/OS XL C and OPT(3) it gets compiled into a single instruction:

41F0  0000        000013 | LA       r15,0

Which looks plain wrong to me.

I think it is because none of the variables referenced by the __asm statement is reused within the function.

If I just change the return statement to look like the following:

 return functRC;

The function is properly compiled into

0000DA  58F2  0000        000005 |                   L r15,0(r2,)
0000DE  1814              000005 |                   LR r1,r4
0000E0  5811  0018        000005 |                   L r1,24(r1,)
0000E4  05EF              000005 |                   BALR r14,r15
0000E6  50FD  0098        000005 |                   ST r15,152(r13,)

I do not have a current version at hand to see if this has been fixed.

mario

Reply via email to