On Sun, Feb 23, 2014 at 12:44 AM, David Crayford <[email protected]>wrote:
> Hmm, I'm not getting the same result! When I compile with ARCH(5) there is
> only one strlen() call (SRST) and the value is retained in a register.
>
> BTW, I removed #undef strlen. What is the purpose of that directive?
>
> * int i;
> * for(i=0;i<argc;i++) {
> LTR r1,r1
> LA r3,0
> JNH @1L6
> LA r5,0
> LR r8,r1
> @1L3 DS 0H
>
> * if ('\r' == *(argv i +strlen(argv i )) )
> L r9,(*)uchar*(r5,r2,0)
> LR r11,r9
> NILH r11,H'32767'
> LA r0,0
> LR r10,r11
> SRST r0,r10
> JO *-4
> LR r10,r0
> SLR r10,r11
> LLGC r0,(*)uchar(r10,r9,0)
> CHI r0,H'13'
> JNE @1L5
>
> * *(argv i +strlen(argv i ))='\0';
> AL r10,(*)uchar*(r5,r2,0)
> MVI (*)uchar(r10,0),0
> @1L5 DS 0H
> LA r5,#AMNESIA(,r5,4)
> BRCT r8,@1L3
> * }
> * return 0;
> * }
>
> If I compile using ARCH(9) for our z114 the code is even more succinct. I
> can't pick a hole in it.
>
> * int i;
> * for(i=0;i<argc;i++) {
> LA r3,0
> LTR r1,r1
> JNH @1L6
> LA r5,0
> RISBHG r0,r1,H'0',H'159',H'32'
> @1L3 DS 0H
>
> * if ('\r' == *(argv i +strlen(argv i )) )
> L r10,(*)uchar*(r5,r2,0)
> LA r0,0
> LR r8,r10
> NILH r8,H'32767'
> LR r9,r8
> SRST r0,r9
> JO *-4
> SLRK r8,r0,r8
> LLC r0,(*)uchar(r8,r10,0)
> CHI r0,H'13'
> JNE @1L5
>
> * *(argv i +strlen(argv i ))='\0';
> AL r8,(*)uchar*(r5,r2,0)
> MVI (*)uchar(r8,0),0
> @1L5 DS 0H
> LA r5,#AMNESIA(,r5,4)
> BRCTH r0,@1L3
> * }
> * return 0;
Hum, your results are what I was expecting. Perhaps I missed something in
my compile parameters. Did you compile using JCL? I am using the UNIX "xlc"
command from a UNIX prompt. I don't know why that would make a difference.
Would you mind showing me your compile parameters? What version of z/OS are
you running on? My compile came from a z/OS 1.13 system. I don't know the
maintenance level.
I forgot to remove the #undef line. Without the #undef, you get the
"builtin" code you saw (with the SRST). I then wondered that perhaps if I
forced an actual CALL to the strlen() subroutine, the compiler would
"smarten up" and save the result. In both case, with & without the #undef,
the compiler did not "save" the results as I had hoped. What the #undef
does is force the compiler to use the strlen() function call instead of the
builtin. In the <string.h> include, there is a line like:
#define strlen __strlen
--
Wasn't there something about a PASCAL programmer knowing the value of
everything and the Wirth of nothing?
Maranatha! <><
John McKown
----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN