MVSFORUMS.com Forum Index MVSFORUMS.com
A Community of and for MVS Professionals
 
 FAQFAQ   SearchSearch   Quick Manuals   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

redefines clause display

 
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming
View previous topic :: View next topic  
Author Message
shekar123
Advanced


Joined: 22 Jul 2005
Posts: 528
Topics: 90
Location: Bangalore India

PostPosted: Wed Nov 02, 2005 4:55 pm    Post subject: redefines clause display Reply with quote

Hai all,

I have coded in my pgm and i get the output as below.But i am not able to figure out how exactly the redefines has taken effect and i am not clear with how the output which has come .Can anybody guide me with the solution ?

Code:

01 GROUPA.                   
   05 X PIC S9(4) VALUE +123.
   05 Y REDEFINES X.         
      10 X1 PIC X.           
      10 X2 PIC X.           



OUTPUT
---------

Code:

X1 IS 0
X2 IS 1



My understanding is that variable X takes 4 bytes of storage as 9(4) and sign is punched over the last nibble bits so it will take the form

---------
0|1|2|3
---------

Now Y is redefined and it also takes 4 bytes of storage and it will take the form and since X1 and X2 are alphanumeric they take from the left most bits individually.

---------
0|1|2|3
---------
_________________
Shekar
Grow Technically
Back to top
View user's profile Send private message
SureshKumar
Intermediate


Joined: 23 Jan 2003
Posts: 211
Topics: 21

PostPosted: Wed Nov 02, 2005 5:37 pm    Post subject: Reply with quote

shekar123,
your Y is only 2 bytes ?
Back to top
View user's profile Send private message
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Wed Nov 02, 2005 6:07 pm    Post subject: Reply with quote

shekar123,

Check these topics which will answer your questions

http://www.mvsforums.com/helpboards/viewtopic.php?t=3415&highlight=display

http://www.mvsforums.com/helpboards/viewtopic.php?t=2099&highlight=numproc

Hope this helps...

Cheers

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Ravi
Beginner


Joined: 27 Jun 2005
Posts: 88
Topics: 2

PostPosted: Wed Nov 02, 2005 6:08 pm    Post subject: Reply with quote

Code:
 Make a HEX ON
File-AID - Edit - userid.D1 ------
COMMAND ===>
       X        X1       X2
       4/SNUM   1/AN     1/AN
       (1-4)    (1-1)R   (2-2)R
       1------- 3------- 4-------
****** ***************************
000001 012C     0        1
V      FFFC     F        F
V      0123     0        1
****** ***************************


Make a Hex Off
File-AID - Edit - userid.D1 -----
COMMAND ===>
       X        X1       X2
       4/SNUM   1/AN     1/AN
       (1-4)    (1-1)R   (2-2)R
       1------- 3------- 4-------
****** **************************
000001      123 0        1
****** **************************

s9(4) is not equal to 9(4).
Back to top
View user's profile Send private message
Mervyn
Moderator


Joined: 02 Dec 2002
Posts: 415
Topics: 6
Location: Hove, England

PostPosted: Wed Nov 02, 2005 7:15 pm    Post subject: Reply with quote

SureshKumar has the correct answer.

You're only redefining the first two bytes, which contain '01'.

Cheers,
Merv
_________________
The day you stop learning the dinosaur becomes extinct
Back to top
View user's profile Send private message
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Wed Nov 02, 2005 10:35 pm    Post subject: Reply with quote

Wait a minute. Am I missing something? I don't know COBOL well, so are you saying that COBOL stores signed decimal as a the EBCDIC representation of a packed decimal number? That sounds absolutely crazy! That would mean that for every arithmetic operation, it not only has to do a CVB and convert to decimal (or more likely use the packed arithmetic instructions), but it also has to do a PACK and UNPK? And it wastes 1/2 the available space. Why doesn't it store it as a packed decimal or is that a different COMP type? (Its been years since I did anything with packed decimal; I never really had a need for it, so my memory may be terribly wrong about how things work).
Back to top
View user's profile Send private message Visit poster's website
kolusu
Site Admin
Site Admin


Joined: 26 Nov 2002
Posts: 12376
Topics: 75
Location: San Jose

PostPosted: Thu Nov 03, 2005 5:39 am    Post subject: Reply with quote

semigeezer,

Here is a link which explains the internal storage reprenstation of numeric items in cobol

http://publibz.boulder.ibm.com/cgi-bin/bookmgr_OS390/BOOKS/IGY3PG10/1.3.4.7?DT=20020923143836

Kolusu
_________________
Kolusu
www.linkedin.com/in/kolusu
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Thu Nov 03, 2005 6:06 am    Post subject: Reply with quote

Semigeezer,

Packed data are comp-3. In this case, S9(4), I don't think CVB will be required, only L and AR should do. I will look at some compilation listings to verify.
Back to top
View user's profile Send private message Send e-mail
semigeezer
Supermod


Joined: 03 Jan 2003
Posts: 1014
Topics: 13
Location: Atlantis

PostPosted: Thu Nov 03, 2005 12:56 pm    Post subject: Reply with quote

Thanks to both of you. I'll run a compile w/ the LIST option later today to check.
Back to top
View user's profile Send private message Visit poster's website
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Sat Nov 05, 2005 5:20 am    Post subject: Reply with quote

I finally got time to compile a program with S9(4) and S9(4) COMP-3.

Here is what I found -
Code:

With

05 WK-INDEX                       PIC S9(04).                 

002458         005656     ADD +1 TO WK-INDEX.

Is expanded to

002458  ADD                                                               
   00205A  F223 D318 A103          PACK  792(3,13),259(4,10)     TS2=0   
   002060  FA20 D318 8700          AP    792(3,13),1792(1,8)     TS2=0   
   002066  940F D318               NI    792(13),X'0F'           TS2=0   
   00206A  F822 D318 D318          ZAP   792(3,13),792(3,13)     TS2=0   
   002070  F332 A103 D318          UNPK  259(4,10),792(3,13)     WK-INDEX


Code:

With

05 WK-INDEX                       PIC S9(04) COMP-3.                 

002458         005656     ADD +1 TO WK-INDEX.

Is expanded into

002458  ADD                                                               
   002026  FA20 A103 8700          AP    259(3,10),1792(1,8)     WK-INDEX 
   00202C  940F A103               NI    259(10),X'0F'           WK-INDEX 
   002030  F822 A103 A103          ZAP   259(3,10),259(3,10)     WK-INDEX 


So COMP-3 should appears to be faster.
Back to top
View user's profile Send private message Send e-mail
Dibakar
Advanced


Joined: 02 Dec 2002
Posts: 700
Topics: 63
Location: USA

PostPosted: Mon Nov 07, 2005 4:46 am    Post subject: Reply with quote

I am adding two more on my friend's request.

Code:
000158         001156     05 WK-INDEX                   PIC 9(04). 

002458         005656     ADD +1 TO WK-INDEX.   

002458  ADD                                                                 
   002046  F223 D318 A103          PACK  792(3,13),259(4,10)     TS2=0     
   00204C  FA20 D318 8700          AP    792(3,13),1792(1,8)     TS2=0     
   002052  F332 A103 D318          UNPK  259(4,10),792(3,13)     WK-INDEX   
   002058  96F0 A106               OI    262(10),X'F0'           WK-INDEX+3


Code:
000158         001156     05 WK-INDEX                   PIC S9(04) COMP.

002458         005656     ADD +1 TO WK-INDEX.     

002458  ADD                                                                   
   002004  4820 80E6               LH    2,230(0,8)              PGMLIT AT +22
   002008  4A20 A103               AH    2,259(0,10)             WK-INDEX     
   00200C  4020 A103               STH   2,259(0,10)             WK-INDEX     
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic   printer-friendly view    MVSFORUMS.com Forum Index -> Application Programming All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


MVSFORUMS
Powered by phpBB © 2001, 2005 phpBB Group