Alignment of COBOL 01-levels



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Alignment of COBOL 01-levels

Postby nikesh_rai » Mon Oct 21, 2013 3:55 pm

Hi Guys,

I was going through a link. where two terms were used mode 4 and mode 8. I want to know what are these modes and how I can identify which mode is being used in my shop.

Here is the link for reference:

Link to competitor site removed
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 198
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Alignment of COBOL 01-levels

 

Re: What is mode 4 and mode 8 in cobol

Postby BillyBoyo » Mon Oct 21, 2013 4:28 pm

A "word" is four bytes long. A double-word is eight bytes long.

I think, although I have not come across that particular term before, mod4 is relating to a word, and mod8 a double-word.

In IBM COBOL 01-levels are aligned on double-word boundaries. This means each 01 uses a minimum of eight bytes of storage, and storage is always used by an 01 in multiples of eight bytes.

The 77-level used to behave differently, with no alignment. These days 77-levels also align on a double-word boundary,

I'll have to kill your link.

If require further assistance on this, just continue this with your own question.

PS. I will edit the title shortly.
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: What is mode 4 and mode 8 in cobol

Postby nikesh_rai » Mon Oct 21, 2013 4:41 pm

Thanks Billy,

In that case, I have one more doubt that word boundaries alignment comes in effect when we use SYNC clause, otherwise the field value starts just after the last used byte. So, in this case how we can explain these terms. It is little bit contradictory.. :)

As the comment says:
a lvl-77 is addressed at a mod4
(or mod8 - i forget and am unwilling to look at a listing to find out)

let us say it is mod4.

77 flag1 pic x(01).   address 0000
77 flag2 pic x(01).   address 0004
77 flag3 pic x(01).   address 0008


that means address 0001 thru 0003 and 0005 thru 0007 are unused.

where as:

01  flags.                    address 0000
     02 flag1 pic x(01).      address 0000
     02 flag2 pic x(01).      address 0001
     02 flag3 pic x(01).      address 0002


there are no unsued memory bytes in the above

if the addressing is allocated at mod8 (which i think it is)
there would be an additional 4 bytes between the lvl-77's
that would not be used.


There should not be any unused space until we use SYNC clause.
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 198
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time

Re: Alignment of COBOL 01-levels

Postby BillyBoyo » Mon Oct 21, 2013 6:03 pm

77s (these days) align on double-word boundaries. SYNC cannot not change that.

01s align on double-word boundaries. Their subordinate items, however, are not aligned. Unless a binary value and you supply SYNC. In which case you may get "slack bytes" - "gaps".

Unless the documentation of a product you are using specifies that you must use SYNC, don't use it. It is a throwback to distant times.

In those distant times, at least some "halfword" machine-instructions required that the source field started on a halfword boundary and would abend if given an address which was not on a halfword boundary. The COBOL compiler at the time, knowing this, would generate a move to a piece of compiler storage aligned correctly, do the operation, then move it back. The extra code generated could be avoided by specifying SYNC, at the cost of one byte of working-storage.

I have never seen a compiler generate that code. It is a long time since the machine-code itself, the instructions, were changed so that they did not require boundary-alignment.

Forget all about using SYNC, unless a document for something you are using says otherwise. A document. Not "someone" who once heard a rumour and never bothered to check on it. See it in a document :-)

These users thanked the author BillyBoyo for the post:
nikesh_rai (Mon Oct 21, 2013 7:21 pm)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Alignment of COBOL 01-levels

Postby nikesh_rai » Mon Oct 21, 2013 7:21 pm

Thanks a lot Billy.. :)
Thanks
Nikesh Rai
nikesh_rai
 
Posts: 198
Joined: Tue Oct 18, 2011 1:27 am
Has thanked: 17 times
Been thanked: 0 time


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post