Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Regarding Slack Bytes

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming
View previous topic :: :: View next topic  
Author Message
sudheer_kumar

New User


Joined: 27 Dec 2005
Posts: 16

PostPosted: Mon Jan 02, 2006 7:04 pm    Post subject: Regarding Slack Bytes
Reply with quote

During storage allocation few bytes are left unused. These unused bytes are known as slack bytes. Are there any way to use these unused memory i.e slack bytes in the program?
Back to top
View user's profile Send private message

i413678
Currently Banned

Active User


Joined: 19 Feb 2005
Posts: 112
Location: chennai

PostPosted: Mon Jan 02, 2006 8:22 pm    Post subject: Re: Regarding Slack Bytes
Reply with quote

Hi,

To maintain the synchronization between the adjuacent locations we are using slack bytes.

I dont think so these can be read.

correct me if I am wrong.....

pavan
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Tue Jan 03, 2006 6:12 am    Post subject:
Reply with quote

Hi Sudheer,

My apologies to all. I should have mentioned that the slack bytes discussed here are not generated unless you code a SYNC clause after the PIC when defining a COMP or COMP-x field. I'll change the examples below to reflect that oversight.

You can't directly access these bytes, but by managing your WS better you can prevent their creation in some cases. See e.g. below.
Code:

01 wrk-area-1.
05 a   pic x.
05 b   pic s9(010) comp sync.
05 c.
    10 c1   pic x(005).
    10 c2   pic x(005).

01 wrk-area-2.
05 b   pic s9(010) comp sync.
05 a   pic x.
05 c.
    10 c1   pic x(005).
    10 c2   pic x(005).


Both wrk areas are almost identical, except for the placement of variable "a". But 22 bytes of storage is allocated to wrk-area-1 and only 19 is allocated to wrk-area-2.

That's because slack bytes must be added before the "b" variable in wrk-area-1. Since the 01 level is automatically placed on a dblwrd boundary, the "b" in wrk-area-2 is already positioned on the required fullwrd bound.

The "b" in wrk-area-1 is 1 byte beyond the dblwrd bound because of "a" being allocated before it. The next fullwrd bound is 3 bytes beyond, which represents the difference in length between the 2 wrk areas.

Since the compiler generates code to move the COMP flds to aligned wrk fields, using SYNC will eliminate the need for this kind of overhead.

So the lesson to be learned here is to organize your WS where possible when using SYNC; it even can help when you don't use SYNC:

comp-2 flds (dblwrd bound)
comp-1 flds (fullwrd bound)
4 byte comp flds (fullwrd bound)
2 byte comp flds (halfwrd bound)
all others (no bounds required)

It takes a little planning, but not that much. icon_smile.gif
Back to top
View user's profile Send private message
sudheer_kumar

New User


Joined: 27 Dec 2005
Posts: 16

PostPosted: Wed Jan 04, 2006 5:27 pm    Post subject: Regarding Slack Bytes
Reply with quote

Hi,
Jack. Thankx for your reply. But I didn't understand about what u are saying about below things?

comp-2 flds
8 byte comp flds
comp-1 flds
4 byte comp flds
2 byte comp flds
all others

Regards,
Sudheer Kumar M
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Thu Jan 05, 2006 8:36 am    Post subject:
Reply with quote

Hi Sudheer,

All the comp fields mentioned there will align on half wrd, full wrd, or double wrd boundaries if SYNC is used in their PICs. Even if you don't use SYNC and you start at the 01 level, all the data will align on the proper boundaries if you allocate as shown there.

For example: comp-1 is a full wrd fld, comp-2 is a double wrd fld. Comp flds with a 1-4 pic 9 [e.g. 9(4)] is a half wrd fld; 5-9 pic 9 (not sure of upper limit) is a full wrd fld; 10-18 pic 9 is a double wrd fld.
Back to top
View user's profile Send private message
mijanurit
Currently Banned

New User


Joined: 26 Aug 2005
Posts: 33
Location: bangalore

PostPosted: Sat Jan 07, 2006 10:05 am    Post subject: Re: Regarding Slack Bytes
Reply with quote

Hi mmwife,

If we use SYNC clause in data item, then storing will start from a new word boundary if available space is not found.

e.g.
01 wr-area1.
02 data1 pic x.
02 data2 pic s9(8) COMP sync.
Size of S9(8) comp is 4 bytes.
There will be 3 slack bytes and total space occupied by wr-area1 is 8 bytes.

01 wr-area1.
02 data1 pic x.
02 data2 pic s9(4) COMP sync.
There is no slack bytes.
Because S9(4) COMP require 2 bytes and this can be easily place in the previous word.
Here size of wr-area1 is 3 bytes.

Here in ur example I want to say;

Code:
01 wrk-area-1.
05 a pic x.
05 b pic s9(010) comp sync.
05 c.
10 c1 pic x(005).
10 c2 pic x(005).
01 wrk-area-2.
05 b pic s9(010) comp sync.
05 a pic x.
05 c.
10 c1 pic x(005).
10 c2 pic x(005).


Wrk-area-1 will occupy 22 bytes and wrk-area-2 will occupy 19 bytes.

Plz correct me if I am wrong.

Plz tell whether the SYNC clause dependent on level number( 01, 02,77…)

Regards
mijanurit
Back to top
View user's profile Send private message
dneufarth

Active User


Joined: 27 Apr 2005
Posts: 239
Location: Cincinnati OH USA

PostPosted: Sat Jan 07, 2006 12:17 pm    Post subject:
Reply with quote

Just curious,

why would you want to use them?


Dave
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sun Jan 08, 2006 12:37 pm    Post subject:
Reply with quote

Hi mijanurit,
You said:
Quote:
01 wr-area1.
02 data1 pic x.
02 data2 pic s9(4) COMP sync.
There is no slack bytes.
Because S9(4) COMP require 2 bytes and this can be easily place in the previous word.
Here size of wr-area1 is 3 bytes.


That's not quite right. The 01 wr-area1 begins on a dblwrd bound. The 02 data1 takes one byte; the 02 data2 is a halfwrd COMP field and requires a halfwrd bound because of the SYNC clause (that requires one byte). The total length of wr-area1 is 4: 1+1+2.

You also said:
Quote:
Wrk-area-1 will occupy 22 bytes and wrk-area-2 will occupy 19 bytes.


I mistakenly said that wrk-area-1 will occupy 26 bytes, assuming a dblwrd COMP field would align on a dblwrd bound. The manual says that the max alignment for COMP fields is a fullwrd bound. I'll correct my post to reflect this.

And finally you said:
Quote:
Plz tell whether the SYNC clause dependent on level number( 01, 02,77?)


I'm not sure I understand the ques, but I'll tell you what I remember about SYNC.

As I recall 01 levels are automatically aligned on a dblwrd bound. 02 levels are not, so you must know the starting pos of the 02 level (or any data level except 01) to determine the number of slack bytes generated by the SYNC clause(s). I'm not sure if 77 levels are auto aligned and if not, whether they can be SYNCed by the pgmr. It's easy enough to check though.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> COBOL Programming All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts FIXED BIN (31) and FIXED BIN (63) - H... sundarkudos PL/I & Assembler 4 Thu Nov 05, 2015 1:11 pm
No new posts Syncsort 1.4.2 - Variable file - Igno... TS70363 SYNCSORT 9 Fri May 22, 2015 9:45 pm
No new posts OUTREC fill bytes restants josessegura DFSORT/ICETOOL 5 Thu Apr 16, 2015 12:40 am
No new posts ICE039A F INSUFFICIENT MAIN STORAGE -... bijoybabu83 DFSORT/ICETOOL 3 Thu Sep 25, 2014 4:29 am
No new posts Extract last 2 bytes from a field in ... VivekKhanna DFSORT/ICETOOL 4 Wed Jul 30, 2014 2:50 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us