View previous topic :: View next topic
|
Author |
Message |
k_rajesh
New User
Joined: 14 May 2010 Posts: 14 Location: hyd
|
|
|
|
Hi, I am facing a basic problem and request you all to kindly correct my ignorace. I was trying to initialize a variable CVAL DC 41CL1'@' using the following instruction:
MVI CVAL,C' '
MVC CVAL+1(L'CVAL-1),CVAL
Only 2 chars of the variable CVAL were initialized to spaces.
After sometime when I defined the variable as CVAL DS CL41 I was able to initialize it to spaces.
Now my queries:
1. Why the first process of initialization partially failed.
2. Inspite being a failure, why only 2 bytes of CVAL were initialized to spaces with the first process. Has it got something to do with length (41CL1)??
Kindly help.
Yours truly,
K. Rajesh |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8697 Location: Dubuque, Iowa, USA
|
|
|
|
41CL1 means you have 41 occurrences of a one-byte field. The length of a one-byte field is 1 byte, so your initialization logic fails. Specifically, the first byte was initialized by the MVI and the next byte by the MVC. Then the length was detected as being exceeded and the MVC stopped. 2 bytes initialized.
CL41 means you have 1 occurrence of a 41-byte field. The initialization logic will succeed for this field.
Both reserve 41 bytes, but they are handled differently since the lengths are 40 bytes apart. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
If you want this to work properly, you need to define this as a CL41. As a 41CL1, the MVC length will be for 01-Byte and therefore, that's why only two-bytes were set to X'40'.
Or, directly after the CVAL definition define -
And issue -
Code: |
MVI CVAL,C' '
MVC CVAL+1(CVALLEN-1),CVAL
|
I must assume this is Batch Assembler and not CICS?
Constants should be "constant" and not require any type of execution initialization.
Bill |
|
Back to top |
|
|
k_rajesh
New User
Joined: 14 May 2010 Posts: 14 Location: hyd
|
|
|
|
Hi Frens,
Thanks for the explanation. I always used to think that the only difference between Cl41 and 41Cl1 is the way storage is allocated. Now I even understand that MVC handles them differently.
I wonder if there are nay more differences like these???
Can you suggest any reference or if the differences are small can you list one or two here??
Thanks,
Rajesh. |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
Quote: |
I always used to think that the only difference between Cl41 and 41Cl1 is the way storage is allocated. |
Code: |
var1 ds clxx
var2 ds xxcl1 |
reserve/allocate/increment_the_location_counter exactly (by) the same amount
for var1 the lenght of the elementary item is xx
for var2 the lenght of the elementary item is 1
is almost i said almost like defining
a string of xx bytes
an array of xx elements 1 byte each
and assembler will treat the lengths accordingly |
|
Back to top |
|
|
mkreutzian
New User
Joined: 26 Jan 2007 Posts: 3 Location: Iowa
|
|
|
|
You can slightly modify your DC/DS configuration to make what you want to do work:
CVAL DS 0CL41
DC 41CL'@'
this will give you the length for the MVC and still not require you to type in 41 '@' signs, but then again, why put them in a constant if you are just going to initialize it to space. |
|
Back to top |
|
|
k_rajesh
New User
Joined: 14 May 2010 Posts: 14 Location: hyd
|
|
|
|
Hi Frens,
Thankyou all for clarifying my doubts.
Regards,
Rajesh.
mkreutzian wrote: |
You can slightly modify your DC/DS configuration to make what you want to do work:
CVAL DS 0CL41
DC 41CL'@'
this will give you the length for the MVC and still not require you to type in 41 '@' signs, but then again, why put them in a constant if you are just going to initialize it to space. |
|
|
Back to top |
|
|
k_rajesh
New User
Joined: 14 May 2010 Posts: 14 Location: hyd
|
|
|
|
Hi Bill,
I got your point. I will improve the coding standard. From now on constants will be constants. Sorry for the delay in reply.
Rajesh.
Bill O'Boyle wrote: |
If you want this to work properly, you need to define this as a CL41. As a 41CL1, the MVC length will be for 01-Byte and therefore, that's why only two-bytes were set to X'40'.
Or, directly after the CVAL definition define -
And issue -
Code: |
MVI CVAL,C' '
MVC CVAL+1(CVALLEN-1),CVAL
|
I must assume this is Batch Assembler and not CICS?
Constants should be "constant" and not require any type of execution initialization.
Bill |
|
|
Back to top |
|
|
|