View previous topic :: View next topic
|
Author |
Message |
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
Hi ,
I was reading book , always see something like boundary alignments?
What exactly we need this for ?
Code: |
DS 0F Assure correct boundary alignments
BLANKS DC CL22' ' Initial value for name
NAME DS CL22 Dummy NAME field for tables
AGE DS F Dummy AGE field for tables
NEXTENT DS 0H Dummy next entry in a table |
By using DS 0F will align the boundary ?
Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Googling hlasm boundary alignment returns about 2,430 hits and the first one has
Quote: |
Alignment of constants
HLASM Language Reference
SC26-4940-06
The assembler aligns constants on different boundaries according to the following:
•On boundaries implicit to the type of constant (see "Implicit Boundary Alignment" in Table 2) when no length is specified.
•On byte boundaries (see "Boundary Alignment" in Table 2) when an explicit length is specified.
Bytes that are skipped to align a constant at the correct boundary are not considered part of the constant. They are filled with binary zeros.
Notes: 1.The automatic alignment of constants and areas does not occur if the NOALIGN assembler option has been specified.
2.Alignment can be forced to any boundary by a preceding DS or DC instruction with a zero duplication factor. This occurs whether or not the ALIGN option is set. |
You can reference the manual to see table 2 - tables do not really paste well on this forum. |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
Many instructions in the original System/360 had very strict restrictions on where, in storage, their operands were located. The Load (L) instruction, for example, required the data referenced by the instruction had to be at a storage location that was divisible by 4.
Most of these storage alignment restrictions were formally removed with System/370, though with the warning that execution time for the instruction could be slowed if the old storage alignment rule was not followed.
The Assembler, Linkage Editor, program fetch, and storage management assist the programmer in several ways.- The Assembler assumes a CSECT is always aligned on a double word boundary.
- All machine instructions are aligned on a halfword boundary – this is still required by the hardware – by the Assembler.
- The Linkage Editor prepares a load module so that each CSECT in on a double word boundary within a load module.
- Program Fetch always loads a load module on a double word boundary, unless the module is defined with a more restrictive boundary alignment.
- The GETMAIN (and STORAGE) macros always allocate storage starting on a double word boundary.
The DC and DS Assembler instructions perform alignment based on the data type specified by the programmer. A DC F'0' Assembler instruction, for example, will align the data on a word boundary. You can override the default boundary alignment by specifying a length: DC FL4'0', for example, may not be aligned on a word boundary.
In the topic starter's example, the DS 0F will cause the Assembler to align storage on a word boundary. Since 0F does not generate any storage, the next location, BLANKS DC CL22' ' will be aligned on a word boundary, though there is no obvious reason why it should be. After BLANKS, there are two bytes of undefined data because AGE DS F will be aligned on a word boundary. NEXTENT DS 0H will be aligned on a word boundary for two reasons: AGE is defined on a word boundary and its data contains 4 bytes, so the next location, by definition, will also be on a word boundary. The Integral Boundaries topic in z/Architecture Priciple of Operation discusses this matter. |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
Aee you doing something like this?
Code: |
TBENT DSECT
NAME DS CL22
AGE DS F
TBSIZE EQU *-TBENT
...
LA 2,TABLE Compute address of the start of
* the table
USING TBENT,2 Establish table entry addressability
LOOP ...
LA 2,TBSIZE(,2) Compute next table address
B LOOP Do it again |
|
|
Back to top |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
Thank you very much for your answer.
For DS 0F ,does it has any 'domain' ? or any DS or DC below DS 0F will align on full word boundary until next DS 0*?
Thanks |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No, it simply sets the next available address to the next available fullword boundary for the next storage definition.
In the example you quote from the book, its usage seems fairly pointless.
If you want consecutive fields one-to-seven-byte fields to on a fullword boundary, you'd need a second DS 0F.
It has no "scope" or "domain", simply affect the next defined storage (can even be program code if you arrange it that way). |
|
Back to top |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
Data area boundary alignment does not have a "domain" as understood in high level languages, but it does have a "domain," of sorts: the current CSECT or DSECT.
For example, in
Code: |
TBENT DSECT
NAME DS CL22
AGE DS F
...
PGM CSECT
...
DS 0F
BLANKS DC CL22' '
ZERO DC F'0' |
The "domain" for AGE is the TBENT DSECT, and any space skipped between NAME and AGE is expressed in each instance of the TBENT DSECT.
In a way, symbol domains are one thing I miss in Assembler compared with, for example, C. For example, in
Code: |
struct tbent
{
struct tbent *next;
char name[ 22 ];
int age;
};
struct something
{
struct something *next;
char name[ 22 ];
int age;
}; |
the symbol next appears in the tbent structure and the something structure. Of course you had to be careful in using the symbol, even if the same name was not used elsewhere.
The C compiler may do boundary alignment, by the way, and does cause problems from time to time. In my little example, there may be space skipped between name and age in both structures. |
|
Back to top |
|
|
|