COMP variables and SYNC and word boundary.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
alpna
Registered Member
Posts: 56
Joined: Fri Jun 21, 2013 10:35 pm

COMP variables and SYNC and word boundary.

Post 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.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1905
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa

Re: COMP variables and SYNC and word boundary.

Post 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.
alpna
Registered Member
Posts: 56
Joined: Fri Jun 21, 2013 10:35 pm

Re: COMP variables and SYNC and word boundary.

Post 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...
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1905
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa

Re: COMP variables and SYNC and word boundary.

Post 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.
dick scherrer
Former Team Member
Posts: 62
Joined: Wed Aug 07, 2013 6:43 pm

Re: COMP variables and SYNC and word boundary.

Post 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.
Hope this helps,
d
Post Reply Previous topicNext topic

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”