IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Why use 0 in DS assmebler code ?


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
jackzhang75

Active User


Joined: 09 Jun 2014
Posts: 125
Location: US

PostPosted: Fri Apr 10, 2015 1:30 am
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

Moderator Emeritus


Joined: 09 Mar 2011
Posts: 7309
Location: Inside the Matrix

PostPosted: Fri Apr 10, 2015 1:49 am
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: 125
Location: US

PostPosted: Fri Apr 10, 2015 7:40 pm
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: 2455
Location: Hampshire, UK

PostPosted: Fri Apr 10, 2015 11:00 pm
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 Member


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

PostPosted: Sat Apr 11, 2015 6:12 am
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: 125
Location: US

PostPosted: Fri May 15, 2015 12:17 am
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: 8696
Location: Dubuque, Iowa, USA

PostPosted: Fri May 15, 2015 12:34 am
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts run rexx code with jcl CLIST & REXX 15
No new posts Compile rexx code with jcl CLIST & REXX 6
No new posts REXX code to expand copybook in a cob... CLIST & REXX 2
No new posts VSAM return code 23 - for a Random read COBOL Programming 4
No new posts Monitoring production job progress. N... JCL & VSAM 4
Search our Forums:

Back to Top