That code sequence is what I remember. But I did my own, minor testing and my results with OPT(FULL) and TRUNC(BIN) and TRUNC(OPT). And it basically was LH/AH/STH or LA/AH/STH.
In the fullword case, all the SRDAs and extra instructions are done to detect overflow. I guess don't know why they are being generated, except that they are required even in the TRUNC(BIN) & TRUNC(OPT) environments because the ADD (and all the other computational verbs) may have an ON SIZE ERROR clause. Apparently this clause is required to "fire" if the result of the computation would not fit into the number of digits specified in the PICTURE clause. And the compiler doesn't modify the instruction sequence even if the sentence does not have an ON SIZE ERROR clause. I don't know if I'm saying that very well. Basically the COBOL code generator has one code sequence to add two fullwords together. It's only when it goes to store the result that it looks at the TRUNC option to see if it can store the binary result, or needs to truncate the result based on the TRUNC option. It turns out that the case of using halfwords these extra instructions are not needed because the overflow detection can be done by a simple compare of the absolute value of the result being greater than the number of decimal digits in the receiving field. -- John McKown Systems Engineer IV IT Administrative Services Group HealthMarkets® 9151 Boulevard 26 . N. Richland Hills . TX 76010 (817) 255-3225 phone . john.mck...@healthmarkets.com . www.HealthMarkets.com Confidentiality Notice: This e-mail message may contain confidential or proprietary information. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message. HealthMarkets® is the brand name for products underwritten and issued by the insurance subsidiaries of HealthMarkets, Inc. -The Chesapeake Life Insurance Company®, Mid-West National Life Insurance Company of TennesseeSM and The MEGA Life and Health Insurance Company.SM > -----Original Message----- > From: IBM Mainframe Discussion List > [mailto:IBM-MAIN@bama.ua.edu] On Behalf Of Frank Swarbrick > Sent: Thursday, April 12, 2012 1:07 PM > To: IBM-MAIN@bama.ua.edu > Subject: Re: Modernizing the BCP code ? > > I actually checked that. The code is slightly different, but > I don't see that it's much better. > > 01 FULLWORD-SORTOF PIC S9(9) BINARY VALUE +999999999. > > > 000009 ADD 100 TO FULLWORD-SORTOF > > > 000354 GN=16 EQU * > 000354 4820 A01C LH 2,28(0,10) > PGMLIT AT +20 > 000358 8E20 0020 SRDA 2,32(0) > 00035C 5840 8000 L 4,0(0,8) > FULLWORD-SORTOF > 000360 8E40 0020 SRDA 4,32(0) > 000364 1A42 AR 4,2 > 000366 1E53 ALR 5,3 > 000368 58B0 C02C L 11,44(0,12) > PBL=1 > 00036C 47C0 B16C BC 12,364(0,11) > GN=17(000374) > 000370 5A40 C004 A 4,4(0,12) > SYSLIT AT +4 > 000374 GN=17 EQU * > 000374 5D40 C000 D 4,0(0,12) > SYSLIT AT +0 > 000378 5040 8000 ST 4,0(0,8) > FULLWORD-SORTOF > > 01 FULLWORD-SORTOF PIC S9(9) COMP-5 VALUE +999999999. > > > 000009 ADD 100 TO FULLWORD-SORTOF > > 000350 GN=16 EQU * > 000350 5820 8000 L 2,0(0,8) > FULLWORD-SORTOF > 000354 8E20 0020 SRDA 2,32(0) > 000358 4840 A01C LH 4,28(0,10) > PGMLIT AT +20 > 00035C 8E40 0020 SRDA 4,32(0) > 000360 1A24 AR 2,4 > 000362 1E35 ALR 3,5 > 000364 58B0 C028 L 11,40(0,12) > PBL=1 > 000368 47C0 B16C BC 12,364(0,11) > GN=17(000370) > 00036C 5A20 C000 A 2,0(0,12) > SYSLIT AT +0 > 000370 GN=17 EQU * > 000370 5030 8000 ST 3,0(0,8) > FULLWORD-SORTOF > > > Of course I am not an assembler programmer, so maybe it is better? > > Frank > > > > ----- Original Message ----- > > From: David Andrews <d...@lists.duda.com> > > To: IBM-MAIN@bama.ua.edu > > Cc: > > Sent: Thursday, April 12, 2012 11:23 AM > > Subject: Re: Modernizing the BCP code ? > > > > On Thu, 2012-04-12 at 12:45 -0400, McKown, John wrote: > >> I am constantly amazed at the amount of code generate by a simpe: > >> > >> ADD +1 TO WS-INTEGER. > >> > >> when WS-INTEGER is defined as PIC S9(9) BINARY > > > > Try defining it as COMP-5 (or compile with TRUNC(BIN)) and > see if that > > improves the generated code? > > > > -- > > David Andrews > > A. Duda & Sons, Inc. > > david.andr...@duda.com > > > > > ---------------------------------------------------------------------- > > For IBM-MAIN subscribe / signoff / archive access instructions, > > send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN > > > > ---------------------------------------------------------------------- > For IBM-MAIN subscribe / signoff / archive access instructions, > send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN > > ---------------------------------------------------------------------- For IBM-MAIN subscribe / signoff / archive access instructions, send email to lists...@bama.ua.edu with the message: INFO IBM-MAIN