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
 

 

Why use 0 in DS assmebler code ?

 
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: Fri Apr 10, 2015 1:30 am    Post subject: Why use 0 in DS assmebler code ?
Reply with quote

I am new to the assembler, can someone help me explain why in following code, use '0' which means not allocate the storage ...

Code:
TMAPLCDE DS    0CL5


Also another question is i see some program define many different length like, how to decide how long should to define or whats the length i need ??

Code:
DS    0CL5
DS    CL1
DS    CL3
DS    CL1
         
DS    CL7
DS    CL1
DS    CL26
DS    CL2
DS    CL9
EQU   12 


Thank you very much !!
Back to top
View user's profile Send private message

Bill Woodger

DFSORT Moderator


Joined: 09 Mar 2011
Posts: 7236

PostPosted: Fri Apr 10, 2015 1:49 am    Post subject: Reply to: Why use 0 in DS assmebler code ?
Reply with quote

1) The 0 prefix allows you to define a name to reference one or more fields defined after it.

If you know COBOL, it is like a group-item, or a REDEFINES.

2a) Your data determines the lengths of fields.

If you have two fields which are being multiplied, you need a field big enough to hold the result (or you need to deal with the overflow).

If you know your data, the limits of your data, that will help you decide beyond just using maths.

If you are going to "edit" a field for display, then the length of the edit-mask is determined by the required format of the output.

2b) Sometimes there are things which require a particular size, or have a particular limit.
Back to top
View user's profile Send private message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 106
Location: windsor

PostPosted: Fri Apr 10, 2015 7:40 pm    Post subject:
Reply with quote

Hi Bill,

Thank you for your answer.

I still not quite understand "
1) The 0 prefix allows you to define a name to reference one or more fields defined after it. "

Can you give me example ?
Back to top
View user's profile Send private message
Nic Clouston

Global Moderator


Joined: 10 May 2007
Posts: 1715
Location: UK

PostPosted: Fri Apr 10, 2015 11:00 pm    Post subject:
Reply with quote

Quote:
Can you give me example ?

You gve an example yourself! But here is another one:

Code:

IREC     DS    0CL23              COURSE record - 23 bytes long
ICID     DS    CL5                1-5   Courese ID
ICDESC   DS    CL15               6-20  Course Description
ICHRS    DS    CL1                21-21 Course Hours
ICRLF    DS    CL2                22-23 CRLF - end of record (DOS/Windoze)
Back to top
View user's profile Send private message
steve-myers

Active User


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

PostPosted: Sat Apr 11, 2015 6:12 am    Post subject:
Reply with quote

In my code, you will often see something like this -
Code:
DATA     DC    P'12345'
EDMASK   DC    0C' NNN.NN'
         DC    C' ',X'202120',C'.',X'2020'
OUTAREA  DC    CL(L'EDMASK)' '

The 0C' NNN.NN' is just a mnemonic of what the edit mask and output looks like and it provides a length for the edit mask. The actual edit mask is C' ',X'202120',C'.',X'2020' Character data is character data, not some obscure hexadecimal code. The only hexadecimal characters are the digit select codes. The code to use this data is -
Code:
         MVC   OUTAREA,EDMASK
         ED    OUTAREA,DATA

Now, of course, if the edit mask is being used just once you can edit directly to the edit mask. If it is used several times you copy the edit mask to the output area.
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 12:17 am    Post subject:
Reply with quote

Thank you for your reply.

Another question is why we need to define the big storage area first by using DS 0CL5 ? Why not directly define sub storage area maybe much simple ? If we do this way , anything wrong ?
Back to top
View user's profile Send private message
Robert Sample

Global Moderator


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

PostPosted: Fri May 15, 2015 12:34 am    Post subject:
Reply with quote

In the particular example you showed, there was no reason to use the 0CL5. There are cases, however, where it comes in handy:
Code:
PLINE    DS    0CL133
CC       DS    CL1' '
USERNAME DS    CL25
         DS    CL4' '
USERADDR DS    CL80
         DS    CL4' '
USERACCT DS    CL11
         DS    CL8' '
allows you to fill in data and then use PUT OUTFILE,PLINE to print the entire 133 bytes as one record.
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 PL/I code tuning/Performance improvement Virendra Shambharkar PL/I & Assembler 4 Mon Dec 05, 2016 11:57 am
No new posts What is the code in CLIST to enable t... jackzhang75 CLIST & REXX 1 Fri Dec 02, 2016 3:02 am
No new posts IDEAL - Code Retrieval yugendran CA Products 0 Fri Nov 25, 2016 3:27 pm
This topic is locked: you cannot edit posts or make replies. Need to code a Rexx PGM sundaram.naveen CLIST & REXX 18 Thu Oct 06, 2016 6:45 pm
No new posts Need Help in understanding what is th... mainakdalal PL/I & Assembler 9 Mon Oct 03, 2016 8:03 pm


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