Monday, August 29, 2011

SYNC Clause and Slack Bytes ??


SYNC clause is specified with COMP, COMP-1 and COMP-2 items. These items are expected to start at half/full/double word boundaries for faster address resolution. SYNC clause does this but it may introduce slack bytes (unused bytes) before the binary item.

Consider the following declaration in the WORKING-STORAGE SECTION:
01 WS-MY-DATA.
05 WS-DATA-ONE PIC X(6).
05 WS-DATA-TWO PIC 9(6) COMP SYNC.
05 WS-DATA-THREE PIC S9(4)V99 COMP-3.

The Starting address of Full-word should end with 0,4,8 or C and that of half-word should end with 0,2,4,6,8,A,C,E. If DATA-ONE starts at 0, it will occupy 0-5 bytes in memory. DATA-TWO - a sync item of full word cannot start at 6. So by SYNC rule, it starts at 8th position. 6th & 7th bytes are unused. So MY-DATA occupies 16 bytes.

cob_fun cob_ques

0 comments:

Post a Comment