Page 1 of 1

COMP variables and SYNC and word boundary.

Posted: Mon Apr 07, 2014 2:47 pm
by alpna
Hi all,

What is the meaning of word boundary? What is its use?

If i declare a variable like this:

Code: Select all

comp s9(4) sync. 

and another like

Code: Select all

comp s9(4)
What is the difference in the two? How will it allocate them?

Please help to understand the concept.

Re: COMP variables and SYNC and word boundary.

Posted: Mon Apr 07, 2014 5:47 pm
by Robert Sample
IBM mainframes, since the advent of the System/360 in 1964, have used 32-bit words. A word therefore consists of 4 8-bit bytes. A word boundary is a memory address evenly divisible by 4, hence pointing to a specific word in memory. When coding WORKING-STORAGE, word boundaries and SYNC aren't really used much any more as IBM has changed the way COBOL handles them over time. However, if you are coding a FILE SECTION FD then using SYNC may cause slack bytes (see the Language Definition manual) to be inserted, changing your LRECL.

Re: COMP variables and SYNC and word boundary.

Posted: Fri Apr 18, 2014 11:02 am
by alpna
Thanks Robert. Do you have a link or can direct how to find one where in I can read about Slack Bytes and the comipler changes? That will help...

Re: COMP variables and SYNC and word boundary.

Posted: Fri Apr 18, 2014 7:29 pm
by Robert Sample
A Google search for enterprise cobol will lead you to the IBM Library for Enterprise COBOL at http://www-01.ibm.com/support/docview.w ... wg27036733 which gives you access to the manuals for all versions of Enterprise COBOL. You can pull up the Language Reference manual for your version, then look in the index for "slack bytes"; in the 5.1 version they are documented on page 225.

Re: COMP variables and SYNC and word boundary.

Posted: Wed Apr 23, 2014 7:13 am
by dick scherrer
Hello,

You can also make up a small test program and place some of these throughout the WS.

Then observe how they are allocated in the generated listing.