IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Doubt on SYNC Clause


IBM Mainframe Forums -> COBOL Programming
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
chikkamurali

New User


Joined: 13 Mar 2005
Posts: 3
Location: hyderabad

PostPosted: Tue Mar 29, 2005 9:24 am
Reply with quote

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
View user's profile Send private message
chandramouli.v

New User


Joined: 21 Mar 2005
Posts: 12

PostPosted: Tue Mar 29, 2005 12:18 pm
Reply with quote

If u use sync clause it will store data internally on word boundaries
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat May 14, 2005 8:53 pm
Reply with quote

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
View user's profile Send private message
brain_s390

New User


Joined: 06 May 2005
Posts: 58
Location: Mumbai

PostPosted: Sun May 15, 2005 12:12 am
Reply with quote

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
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun May 15, 2005 5:27 am
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> COBOL Programming

 


Similar Topics
Topic Forum Replies
No new posts To search DB2 table based on Conditio... DB2 1
No new posts Doubt about pl/1 (job offer) General Talk & Fun Stuff 5
No new posts Sync logic between VSAM files and DB2... COBOL Programming 9
No new posts NOT IN clause in COBOL pgm COBOL Programming 8
No new posts SUSBSCRIPT WITH SIGN IN PIC CLAUSE COBOL Programming 3
Search our Forums:

Back to Top