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
 

 

What's the result of the move statement

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> Mainframe Interview Questions
View previous topic :: :: View next topic  
Author Message
k_sanu4u

New User


Joined: 23 Mar 2007
Posts: 8
Location: india

PostPosted: Thu Apr 12, 2007 4:24 pm    Post subject: What's the result of the move statement
Reply with quote

01 VAR-A PIC X(5) VALUE SPACES.
01 VAR-B PIC 9(5) COMP-3.

MOVE VAR-A TO VAR-B.

WHAT WILL BE THE VALUE OF VAR-B?
Back to top
View user's profile Send private message

guptae

Moderator


Joined: 14 Oct 2005
Posts: 1187
Location: Bangalore,India

PostPosted: Thu Apr 12, 2007 4:31 pm    Post subject:
Reply with quote

Hi k_sanu4u,

Why dont u try urself rather then asking?
Back to top
View user's profile Send private message
William Thompson

Global Moderator


Joined: 18 Nov 2006
Posts: 3158
Location: Tucson AZ

PostPosted: Thu Apr 12, 2007 5:25 pm    Post subject:
Reply with quote

Are you sure you will even be allowed to do that move?
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Thu Apr 12, 2007 10:37 pm    Post subject: Re: What's the result of the move statement
Reply with quote

You can't move char to a packed decimal..
It shouldn't even compile

~Vamsi
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Fri Apr 13, 2007 4:00 am    Post subject:
Reply with quote

My guess is that you'll get X'00000F' which, of course, is packed unsigned zeros. Another possiblity is X'000004', but I think the "sign" gets ORed to an F.
Back to top
View user's profile Send private message
shreevamsi

Active User


Joined: 23 Feb 2006
Posts: 305
Location: Hyderabad,India

PostPosted: Fri Apr 13, 2007 4:24 am    Post subject: Re: What's the result of the move statement
Reply with quote

this was the compilation error:

"' '" and "X-1 (PACKED INTEGER)" did not follow the "MOVE" statement compatibility rules. The statement was discarded.
Back to top
View user's profile Send private message
k_sanu4u

New User


Joined: 23 Mar 2007
Posts: 8
Location: india

PostPosted: Fri Apr 13, 2007 4:13 pm    Post subject:
Reply with quote

i got zeros as answer while execueting ...can u justify ur answers...
Back to top
View user's profile Send private message
agkshirsagar

Active Member


Joined: 27 Feb 2007
Posts: 685
Location: Earth

PostPosted: Fri Apr 13, 2007 5:08 pm    Post subject:
Reply with quote

Quote:
01 VAR-A PIC X(5) VALUE SPACES.
01 VAR-B PIC 9(5) COMP-3.

Explanation
Space = '40' H in EBCDIC
VAR-A = '4040404040'H
After move you will get '00000F' in VAR-B.
See the move worked this way. Only Lower nibbles were considered.
Compiler will generate code for this 'alignment'.

Similarly when there are all 'A's in VAR-A, you will get 11111 (A= C1 H)
When ALL 'B's then you will get 22222 (B= C2 H)
When ALL 'X's then you will get 77777 (X= E7 H)

It can be perceived as upper nibble of each byte is ignored in each move.
Back to top
View user's profile Send private message
mmwife

Super Moderator


Joined: 30 May 2003
Posts: 1592

PostPosted: Sat Apr 14, 2007 8:43 pm    Post subject:
Reply with quote

I'd only add this to Abhijit's excellent explanation:

The 1st step in the conversion produces X'000004' (the two low order nybbles (40) are reversed, not compressed as the others are). Then, because the PIC of VAR-B is unsigned, the low order byte X(04) is ORed to produce X'0F' making the VAR-B value X'00000F'
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 -> Mainframe Interview Questions All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
This topic is locked: you cannot edit posts or make replies. How to move a long alphanumeric data ... lind sh COBOL Programming 8 Mon Dec 05, 2016 7:51 pm
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am
This topic is locked: you cannot edit posts or make replies. Rexx to create GDG by scanning JJ result krish.deepu CLIST & REXX 5 Tue Oct 25, 2016 5:32 pm
No new posts Protection Exception while move 0 to ... Kevin Vaz CICS 10 Tue Oct 18, 2016 4:19 pm
No new posts COBOL DB2 - CALL statement - high CPU... TS70363 DB2 15 Sun Sep 11, 2016 6:07 am


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