View previous topic :: View next topic
|
Author |
Message |
sghosh
New User
Joined: 13 May 2008 Posts: 2 Location: Kolkata
|
|
|
|
Hi,
Before posting this message I searched this site for similar posts but did not find any.
How and when do I use the COMP SYNC clause while declaring vairables?
Would be great if someone can tell me if this was dealt with in this forum before and let me know the link to that post.
Regards
Ghosh |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
the SYNC attribute is related to the way storage for variables is allocated,
the alignment boundaries are
BYTE for strings and equivalent data ( packed and pic things )
HALFWORD for 2 bytes binary numbers
FULLWORD for 4 bytes binary numbers
DOUBLEWORD for 8 bytes things
search the net for "COBOL ALIGNMENT RULES IBM" an You will find lots of links
or more simply click on the manuals link at top of the page and scroll to the cobol section
just a bit of history
one upon a time the operand boundaries were strictly enforced by hardware
an You would get a specification exception trying to use operands with the wrong alignment
- everything was done to save addressing cycles
now everything has been relaxed and alignment is not usually needed any longer
somebody will tell You when to use the SYNC attribute |
|
Back to top |
|
|
sri_mf
Active User
Joined: 31 Aug 2006 Posts: 218 Location: India
|
|
Back to top |
|
|
ksk
Active User
Joined: 08 Jun 2006 Posts: 355 Location: New York
|
|
|
|
Hi,
The SYNCHRONIZED clause explicitly aligns COMP and INDEX data items along their natural WORD boundaries.
If there is no SYNCHRONIZED clause the data items are aligned on byte boundaries.
This clause is used to optimise speed of processing - but it does so at the expense of storage.
COMP SYNC (1 TO 4 Digits) = 2 Byte boundary
COMP SYNC (5 TO 9 Digits) = 4 Byte boundary
COMP SYNC (10 TO 18 Digits) = 8 Byte boundary
INDEX = 4 Byte boundary
KSK |
|
Back to top |
|
|
mytags
New User
Joined: 28 Apr 2008 Posts: 63 Location: US
|
|
|
|
HI
By mentioning Sync clause along with declarion we can make sure that the variable got stored in system from the starting position of the storage.
Like 2 byte or 4 bytes boundaries.We only need to menton as SYNC along with the declaration of the variable in working storage.
But usage of sync clause is actually a wastage in case of storage.
Hari. |
|
Back to top |
|
|
sghosh
New User
Joined: 13 May 2008 Posts: 2 Location: Kolkata
|
|
|
|
Thanks a lot everyone for all the information. :) |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Just 1 note of caution: if you specify SYNC in variables in a non 01 level group item, then move it to another group, those fields may not be SYNCed properly.
May be a good idea to SYNC both groups. |
|
Back to top |
|
|
|