View previous topic :: View next topic |
Author |
Message |
shekar123 Advanced
Joined: 22 Jul 2005 Posts: 528 Topics: 90 Location: Bangalore India
|
Posted: Wed Nov 02, 2005 4:55 pm Post subject: redefines clause display |
|
|
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
---------
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 |
|
 |
SureshKumar Intermediate
Joined: 23 Jan 2003 Posts: 211 Topics: 21
|
Posted: Wed Nov 02, 2005 5:37 pm Post subject: |
|
|
shekar123,
your Y is only 2 bytes ? |
|
Back to top |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Ravi Beginner
Joined: 27 Jun 2005 Posts: 88 Topics: 2
|
Posted: Wed Nov 02, 2005 6:08 pm Post subject: |
|
|
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 |
|
 |
Mervyn Moderator

Joined: 02 Dec 2002 Posts: 415 Topics: 6 Location: Hove, England
|
Posted: Wed Nov 02, 2005 7:15 pm Post subject: |
|
|
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 |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Wed Nov 02, 2005 10:35 pm Post subject: |
|
|
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 |
|
 |
kolusu Site Admin

Joined: 26 Nov 2002 Posts: 12376 Topics: 75 Location: San Jose
|
|
Back to top |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Thu Nov 03, 2005 6:06 am Post subject: |
|
|
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 |
|
 |
semigeezer Supermod
Joined: 03 Jan 2003 Posts: 1014 Topics: 13 Location: Atlantis
|
Posted: Thu Nov 03, 2005 12:56 pm Post subject: |
|
|
Thanks to both of you. I'll run a compile w/ the LIST option later today to check. |
|
Back to top |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Sat Nov 05, 2005 5:20 am Post subject: |
|
|
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 |
|
 |
Dibakar Advanced

Joined: 02 Dec 2002 Posts: 700 Topics: 63 Location: USA
|
Posted: Mon Nov 07, 2005 4:46 am Post subject: |
|
|
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 |
|
 |
|
|