View previous topic :: View next topic
|
Author |
Message |
daves
New User
Joined: 30 Mar 2007 Posts: 7 Location: Bangalore
|
|
|
|
For example:-
01 ws-test.
02 ws-var1 pic x(02)
02 ws-var2 pic s9(06)comp sync.
so if i am storing 10 in ws-var1, in 0th place 1 is stored and 1st place 0 is stored.
and ws-var2 as 4bytes...in book it is give that it starts from 4th position.....2,3 are slack bytes...
[b]my doubts.
1)what is the total size in this case,is it 2(ws-var1)+4(ws-var2)=6.If 6 is the size then 0,1 is used for storing 10, 2,3 slack bytes...it has only 2bytes left........then how can it store?
**2)if s9(10)comp sync then range is 8byte so do it start from 8th position...make 2 to 7 places as slack bytes? |
|
Back to top |
|
|
William Thompson
Global Moderator
Joined: 18 Nov 2006 Posts: 3156 Location: Tucson AZ
|
|
|
|
daves wrote: |
For example:-
01 ws-test.
02 ws-var1 pic x(02)
02 ws-var2 pic s9(06)comp sync.
so if i am storing 10 in ws-var1, in 0th place 1 is stored and 1st place 0 is stored.
and ws-var2 as 4bytes...in book it is give that it starts from 4th position.....2,3 are slack bytes...
[b]my doubts.
1)what is the total size in this case,is it 2(ws-var1)+4(ws-var2)=6.If 6 is the size then 0,1 is used for storing 10, 2,3 slack bytes...it has only 2bytes left........then how can it store?
**2)if s9(10)comp sync then range is 8byte so do it start from 8th position...make 2 to 7 places as slack bytes? |
Actually ws-var2 is 8 bytes, comp items are half or full words and 9(6) is too big for a half word.
So let's try ws-var1 = x(2) and ws-var2 = s9(6) comp sync:
The 01 lines up on a double word,
var1 occupies the first two bytes,
var2 needs to be full word aligned so there are 2 slack bytes,
var2 occupies the next 4 bytes
ws-test has a length of 8 with the sync and 5 without the sync.
Did this answer your question?
There is a good example and explanation in the section on Slack bytes within records |
|
Back to top |
|
|
daves
New User
Joined: 30 Mar 2007 Posts: 7 Location: Bangalore
|
|
|
|
Hi William,
I got my answer n the explaination i needed from the link u provided.
Thnx 4 helping me out |
|
Back to top |
|
|
|