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

What's the result of the move statement


IBM Mainframe Forums -> Mainframe Interview Questions
Post new topic   Reply to topic
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
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: 1208
Location: Bangalore,India

PostPosted: Thu Apr 12, 2007 4:31 pm
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: 3156
Location: Tucson AZ

PostPosted: Thu Apr 12, 2007 5:25 pm
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
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
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
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
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: 691
Location: Earth

PostPosted: Fri Apr 13, 2007 5:08 pm
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
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> Mainframe Interview Questions

 


Similar Topics
Topic Forum Replies
No new posts first column truncated in search result IBM Tools 13
No new posts COBOL - Move S9(11)v9(7) COMP-3 to -(... COBOL Programming 5
No new posts How to move the first field of each r... DFSORT/ICETOOL 5
No new posts SDSF like solution in EJES (store com... All Other Mainframe Topics 4
No new posts executing XCTL command in COBOL witho... CICS 10
Search our Forums:

Back to Top