Re: Layout Hell-o

From: Richard (riplin_at_Azonic.co.nz)
Date: 07/29/04


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.



Relevant Pages

  • Re: Gandalf
    ... The fact that alignment issues come up from several ... people nearly every time the idea of 'What alignment should character x ... of their core beliefs, and which that character takes *despite* ...
    (rec.games.frp.dnd)
  • alignment grid
    ... that it's too simple to pigeon-hole a player's character in a single ... If you accept that a single alignment is too simple, ... behavior of a character or NPC, then one could write a 3x3 grid of ... the DM and the players. ...
    (rec.games.frp.dnd)
  • Re: Lethality of events
    ... It notes that non-paladin characters are allowed to be inconsistent using a greedy LG character as an example while also noting that the DM may alter your alignment if he thinks you are playing in "a way more appropriate to another alignment". ... It is part of their nature". ... On pg 41 it states the following: "No one ever chooses to be a paladin. ...
    (rec.games.frp.advocacy)
  • Re: alignment grid
    ... that it's too simple to pigeon-hole a player's character in a single ... If you accept that a single alignment is too simple, ... outcome for an individual NPC and not once for each action. ... Standard example, a dwarf is LG but hates Orcs so much, ...
    (rec.games.frp.dnd)
  • Re: alignment grid
    ... do any singular action without it really changing their alignment. ... torture to get the info and thus are able to save 100 lives. ... as the above could have a dramatic impact on a character such as a ... paladin. ...
    (rec.games.frp.dnd)