Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

What's mean by boundary allignment in assembler?

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Thu May 14, 2015 2:22 am    Post subject: What's mean by boundary allignment in assembler?
Reply with quote

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
View user's profile Send private message

Robert Sample

Global Moderator


Joined: 06 Jun 2008
Posts: 7904
Location: Bellevue, IA

PostPosted: Thu May 14, 2015 5:47 am    Post subject:
Reply with quote

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
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 460
Location: The Universe

PostPosted: Thu May 14, 2015 6:07 am    Post subject:
Reply with quote

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
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 460
Location: The Universe

PostPosted: Thu May 14, 2015 6:52 pm    Post subject:
Reply with quote

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
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Fri May 15, 2015 1:20 am    Post subject:
Reply with quote

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
View user's profile Send private message
Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7223

PostPosted: Fri May 15, 2015 1:31 am    Post subject: Reply to: What's mean by boundary allignment in assembler?
Reply with quote

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
View user's profile Send private message
steve-myers

Active User


Joined: 30 Nov 2013
Posts: 460
Location: The Universe

PostPosted: Fri May 15, 2015 7:55 pm    Post subject:
Reply with quote

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
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Online Assembler Program Starting point Aditya.Srivastava PL/I & Assembler 4 Fri Jul 08, 2016 6:48 pm
This topic is locked: you cannot edit posts or make replies. MVS Assembler profiles for Pune Locat... shailesh_do Mainframe Jobs 0 Mon Feb 22, 2016 6:21 pm
No new posts ASRA abend calling Assembler from CICS surya8 PL/I & Assembler 13 Thu Sep 10, 2015 7:50 pm
No new posts Is Enterprise PL/I v4.2 compatible wi... sundarkudos PL/I & Assembler 2 Wed Aug 19, 2015 11:15 pm
No new posts Assembler Code to check normal retur... amitc23 PL/I & Assembler 6 Mon Aug 17, 2015 3:52 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us