View previous topic :: View next topic
|
Author |
Message |
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
I am new to the assembler, can someone help me explain why in following code, use '0' which means not allocate the storage ...
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 |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
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 |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
Nic Clouston
Global Moderator
Joined: 10 May 2007 Posts: 2455 Location: Hampshire, UK
|
|
|
|
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 |
|
|
steve-myers
Active Member
Joined: 30 Nov 2013 Posts: 917 Location: The Universe
|
|
|
|
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 |
|
|
jackzhang75
Active User
Joined: 09 Jun 2014 Posts: 125 Location: US
|
|
|
|
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 |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
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 |
|
|
|