View previous topic :: View next topic
|
Author |
Message |
chikkamurali
New User
Joined: 13 Mar 2005 Posts: 3 Location: hyderabad
|
|
|
|
hi friends,
when we code SYNC Clause with comp&comp1 it will introduce slack bytes.can u explain the effective reason for this.and please explain me indetail about SYNC Clause. |
|
Back to top |
|
|
chandramouli.v
New User
Joined: 21 Mar 2005 Posts: 12
|
|
|
|
If u use sync clause it will store data internally on word boundaries |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
Hi Murali,
When arith is performed the compiler generates the appropriate assembler instructions to do this. Some of these instructions require that the data be aligned on half, full, or double word boundaries.
If the data is not so aligned, the compiler allocates appropriately aligned work fields, moves the data there and uses them for the arith. When finished the data is moved back (if necessary); so you can see how this affects performance.
When SYNC is used these moves are not necessary.
P.S. You rarely see SYNC used today. |
|
Back to top |
|
|
brain_s390
New User
Joined: 06 May 2005 Posts: 58 Location: Mumbai
|
|
|
|
For binary data items, the address resolution is faster if they are located at word boundaries in the memory.
E.g: The memory word size is 4 bytes which means that each word will start from an address divisible by 4. If first variable is x(3) and next one is S9(4) comp, then if you do not specify the SYNC clause, S9(4) COMP will start from byte 3. If we specify SYNC clause then the binary data item will start from address 4. The disadvantage is the wastage of memory which is overshadowed as the access to this comp field is much faster !! |
|
Back to top |
|
|
mmwife
Super Moderator
Joined: 30 May 2003 Posts: 1592
|
|
|
|
It's been a long time since I contemplated this stuff, but as I remember if the field was a halfwd binary item SYNC would align it on a halfwd boundary; if a fwd or a cOMP-1, on a fwd bound; if a dblwd or a COMP-2, on a dblwd bound.
But, a word to the wise: if you don't have a VERY good reason to use it, DON'T. There's a lot more to it than was discussed here. Check your COBOL Ref Manual. |
|
Back to top |
|
|
|