What is the purpose of using SYNC in COBOL?

What is the purpose of using SYNC in COBOL?

Can someone explain the purpose of using SYNC in COBOL?

Thanks

#2

SYNC is used for faster computations…

it creates slack bytes(unused space)…..

Ex:

01 ws-var s9(04) comp

it starts from 3rd byte.

01 ws-var s9(04) comp sync

it starts from 4th byte…

Thanks&Regrads,

vijay

#3 SYNC sets storage boundary

SYNC sets storage boundary alignment for the variable you are defining.  Firstly 01 and 77 level variables are always aligned on a double-word boundary (0, 8, 16, 24…) and level variable after the 01 begins on the next byte position, except if SYNC is specified.  A 9(4) COMP variable is aligned to the next half-word, a 9(8) COMP is aligned to the next full-word, and COMP-1/COMP-2 variables are aligned to the next double-word boundary.

#4

As previously explained, sets a storage boundary – re-read the earlier explanaton.

Slack is the bytes “left over” from some field to the next boundary aligned (SYNCed) field.

To see this, suggest you create some code with various short field that are 01 levels as well as some lower levels. Look at the compiled output to see how the compiler aligns things. Then add a few more lower level field (01s are automatically aligned)) and specify SYNC and see the results.

Log in or register to post comments