Re: Layout Hell-o
From: Richard (riplin_at_Azonic.co.nz)
Date: 07/29/04
- Next message: Calvin: "Re: cobol woes"
- Previous message: Warren Simmons: "Re: Layout Hell-o"
- In reply to: JerryMouse: "Re: Layout Hell-o"
- Next in thread: William M. Klein: "Re: Layout Hell-o"
- Reply: William M. Klein: "Re: Layout Hell-o"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: 28 Jul 2004 15:40:43 -0700
"JerryMouse" <nospam@bisusa.com> wrote
> 77-level data items in COBOL told the compiler to ignore this default
> alignment. You'll see programs with tons of 77-level items in
> Working-Storage instead of 01-level items for this original reason. In other
> words, originally:
>
> 01 Data-A Pic X.
> 01 Data-B Pic X.
> 01 Data-C Pic X
>
> took up 12 bytes of storage. Change the "01" in each to "77" and the same
> set takes up only three bytes - because the 01-level forces the compiler to
> begin the data element on a full-word boundary in memory.
I don't think that is true, or is certainly not true in some
implementations.
77 levels are _non-contiguous_ items. This means that they are _not_
contiguous, or at least do not need to be contiguous, whereas you have
it that the 77 level _makes_ them contiguous.
In all implementations that I have used a 77 level it treaded
identically to it being an 01 with no subordinate items. In other
words your example using 01s would take 12 (or 24) bytes and as 77s
would take exactly the same amount of space.
In fact with MicroFocus there is an 'ALIGN' directive which specifies
the alignment boundary to be used for both 01s and 77s. The default
is 8 bytes, hence 24 for the 3 01 or 77s.
The way to defeat slack bytes is to use sub-ordinate items to a
grouping 01.
01 Data-Group.
03 Data-A Pic X.
03 Data-B Pic X.
03 Data-C Pic X.
This takes 3 bytes and will be followed by one or more slack bytes
before the next 01 or 77.
The point about 77s is that they are non-contiguous, the compiler is
allowed to (but need not) insert slack bytes, or move some of these
items elsewhere in memory, or shuffle them in any way it feels like.
01 levels are record items and are expected to have subordinate items.
Each subordinate item _is_ contiguous at the byte level.
Just a historical note: I was given a client support problem back in
the late 60s when a customer couldn't fit his program into the 16Kword
1901A machine. He had 'saved space' by having a series of single
character flags as 03 levels in a record. It turned out that each
reference to one of these flags required 11 words of instructions to
extract and align the character, it being a word machine and rather
clumsy with characters. Changing all those flags to use a word each
saved several Kwords and made it fit.
- Next message: Calvin: "Re: cobol woes"
- Previous message: Warren Simmons: "Re: Layout Hell-o"
- In reply to: JerryMouse: "Re: Layout Hell-o"
- Next in thread: William M. Klein: "Re: Layout Hell-o"
- Reply: William M. Klein: "Re: Layout Hell-o"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|