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

Initialization of DS and DC variable problem.


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

New User


Joined: 14 May 2010
Posts: 14
Location: hyd

PostPosted: Mon May 24, 2010 6:43 pm
Reply with quote

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

Global Moderator


Joined: 06 Jun 2008
Posts: 8697
Location: Dubuque, Iowa, USA

PostPosted: Mon May 24, 2010 6:47 pm
Reply with quote

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

CICS Moderator


Joined: 14 Jan 2008
Posts: 2501
Location: Atlanta, Georgia, USA

PostPosted: Mon May 24, 2010 6:51 pm
Reply with quote

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 -

Code:

CVALLEN  EQU   *-CVAL

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

New User


Joined: 14 May 2010
Posts: 14
Location: hyd

PostPosted: Tue May 25, 2010 1:40 pm
Reply with quote

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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Tue May 25, 2010 1:51 pm
Reply with quote

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

New User


Joined: 26 Jan 2007
Posts: 3
Location: Iowa

PostPosted: Wed Jun 23, 2010 11:55 pm
Reply with quote

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

New User


Joined: 14 May 2010
Posts: 14
Location: hyd

PostPosted: Mon Aug 02, 2010 9:58 am
Reply with quote

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

New User


Joined: 14 May 2010
Posts: 14
Location: hyd

PostPosted: Mon Aug 02, 2010 10:02 am
Reply with quote

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 -

Code:

CVALLEN  EQU   *-CVAL

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
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 Extracting Variable decimal numbers f... DFSORT/ICETOOL 17
No new posts Map Vols and Problem Dataset All Other Mainframe Topics 2
No new posts Variable Output file name DFSORT/ICETOOL 8
No new posts Moving Or setting POINTER to another ... COBOL Programming 2
No new posts parsing variable length/position data... DFSORT/ICETOOL 5
Search our Forums:

Back to Top