Re: Layout Hell-o
From: JerryMouse (nospam_at_bisusa.com)
Date: 07/28/04
- Next message: Lueko Willms: "Re: Layout Hell.: leave it"
- Previous message: Michael Mattias: "Re: cobfd"
- In reply to: Carol: "Re: Layout Hell-o"
- Next in thread: Carol: "Re: Layout Hell-o"
- Reply: Carol: "Re: Layout Hell-o"
- Reply: Lueko Willms: "Re: Layout Hell-o"
- Reply: Chuck Stevens: "Re: Layout Hell-o"
- Reply: Warren Simmons: "Re: Layout Hell-o"
- Reply: Richard: "Re: Layout Hell-o"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 28 Jul 2004 07:56:42 -0500
Carol wrote:
> I have seen that junk! I have cheated by fudging the starting
> poinsts of some of the translated fields.
>
> I see that I may have been on to something. Thank you for telling me
> why that is.
> !
He told you "what." Here's the "why" of "slack" bytes.
Early on, and continuing to this day, there were machines that had a marked
decrease in efficiency if some data fields were not on the proper
(half-word, full-word, double-word) boundary. The program must move these
mis-aligned fields to a proper alignment before they could be operated upon.
For example, assume the computer, in order to do binary arithmetic, could
load the register (where the binary arithmetic was to be done) only from a
memory location on a full-word boundary.
Extra code was generated by the compiler to move the binary-word argument to
a temporary full-word boundary in memory before the register-load
instruction. After the binary computation in the register, additional code
would have to be generated to take the result from the register and store it
in a temporary area then move it from the temporary area to its rightful
place in the program.
In days of yore (and sometimes today), COBOL programmers kept in the front
of their mind these hardware oddities. The compiler, itself, helped by
forcing all "01" level data names to full-word boundaries.
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.
Many of today's machines don't really care about byte alignment. They can do
binary arithmetic in situ, that is, memory-to-memory, without having to load
a register. There are other machines with hardware instructions to load
accumulators/registers without regard for byte alignment of the parameters.
Still, "slack bytes" will be with us forever.
"Slack bytes" are not to be confused with "expansion bytes" (areas stuck in
by the programmer for future use).
- Next message: Lueko Willms: "Re: Layout Hell.: leave it"
- Previous message: Michael Mattias: "Re: cobfd"
- In reply to: Carol: "Re: Layout Hell-o"
- Next in thread: Carol: "Re: Layout Hell-o"
- Reply: Carol: "Re: Layout Hell-o"
- Reply: Lueko Willms: "Re: Layout Hell-o"
- Reply: Chuck Stevens: "Re: Layout Hell-o"
- Reply: Warren Simmons: "Re: Layout Hell-o"
- Reply: Richard: "Re: Layout Hell-o"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|
|