View previous topic :: View next topic
|
Author |
Message |
Harsh Pawar
New User
Joined: 04 Jun 2008 Posts: 25 Location: Noida
|
|
|
|
Hi,
I have a requirement of unpacking a doubleword.
The double word can contain anything varying from 1 to 999999999 (packed value). Since the value is not fixed i am using EXECUTE instruction as shown below:
PS: R08 has value acording to XYZ. e.g if XYZ = 999 then R08=2
EX R08,UNPKXYZ
UNPKXYZ UNPK ABC+10(*-*),XYZ
ABC DS XL30
XYZ DS D
This logic worked in Pack but it is not working for UNPK.
Kindly help.
Regards,
Harry |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Can you show an example or two of ABC and XYZ and what you mean when you say "it is not working" -- do you mean compiler error, run-time error, or the results you get are not what you expected (3 very different "not working" things that could have very different solutions)? |
|
Back to top |
|
|
CICS Guy
Senior Member
Joined: 18 Jul 2007 Posts: 2146 Location: At my coffee table
|
|
|
|
Hex display the double word XYZ when it contains your example of 999.
Which one is it?
99000000
9C000000
or
00000099
0000009C |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
or even
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
I believe you mean dblword XYZ = PL8'999'?
FWIW, I'd use 0 (this is more clear for the next person) as the length for operand-1 and if R8 = F'2', then the UNPK should work, with a result of X'F9F9C9'. But, to avoid the X'C9', OI the last byte of the dblword with X'0F' before unpacking.
An EX against an UNPK (as well as most/all SS instructions) only OR's the length of Operand-1.
HTH....
Regards, |
|
Back to top |
|
|
Harsh Pawar
New User
Joined: 04 Jun 2008 Posts: 25 Location: Noida
|
|
|
|
Sorry for the confusion, let me rephrase the logic with an example.
We have a field Emp-Id which used to be 5 digits only, so my code was using
UNPK ABC+10(5),XYZ and the logic is giving expected o\p i.e:
ABC=EMPLOYEEID12345
Now i want employee-id to include more than 5 digits as well,for this i am using EX instruction.
So i calculated the length of value inside XYZ(if XYZ=000000000123456C the length is 6).
R08 contains 6 -1 = 5 ........ subtracted 1 for machine inst.
LA R08,5
1)
EX R08,UNPKXYZ
UNPKXYZ UNPK ABC+10(*-*),XYZ
when i run above code i get EMPLOYEEID6.
which should have been ABC=EMPLOYEEID123456 since R08 value is 5.
2)
When i tried following code:
UNPK ABC+10(6),XYZ
i am getting correct output
ABC=EMPLOYEEID123456.
But i want to make dynamic and it should work for employee-id having 5 to 10 digits.
PS: The code is not giving any compilation error, there is some flaw in the logic.
Thanks again for showing your interest in this.
Regards,
Harry.
[/i] |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
the EX instruction will or the second byte of the executed instruction full stop
it' s up to you to build it accordingly to the executed instruction specification
for a SS instructions
4 bits for the first operand length and 4 bits for the second one
code snippet ( review as required )
Code: |
...
la Xreg,lenght1
bctr Xreg,0
sll Xreg,4
la Wreg,length2
bctr Wreg,0
or Xreg,Wreg
ex Xreg,unpk
...
unpk unpk target(0),source(0)
source ds ...
target ds ...
|
|
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Enrico,
I stand humbly corrected. Having only used EX in the past on MVC's, XC's and OC's, I made a bad assumption on an SS with an operand-2 length, which the aforementioned instructions don't have. I should have consulted The POPS manual beforehand.
Slowly wiping egg from face |
|
Back to top |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10872 Location: italy
|
|
|
|
Hi Bill !
my remarks were not on reply to Your post ,
I was simply reminding the TS about the workings of the EX instruction ,the quirks of SS instructions
and why he was not getting the expected results
cheers |
|
Back to top |
|
|
quest2008
New User
Joined: 12 Jun 2008 Posts: 22 Location: bangalore
|
|
|
|
Harry ,
If R08 contains the length for XYZ and R07 contains the length for ABC
Decrement the length for both registers by 1.
Here ABC is the first operand and XYZ is the second operand of the UNPK instruction.
Shift bits left for R07 by 4 bits.
Use SLL R07,4 and get the length of both operands in last one byte of R07. You can do this by AR R07,R08 or use OR R07,R08 will work as indicated above by enrico.
BCTR R08,0
BCTR R07,0
SLL R07,4
AR R07,R08
EX R07,UNPKXYZ
UNPKXYZ UNPK ABC+10(0),XYZ(0)
ABC DS XL30
XYZ DS D
Ensure that XYZ will have data in packed format. Other wise you may face abend at UNPK instruction.
Thanks |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Quest200 said -
quest2008 wrote: |
Ensure that XYZ will have data in packed format. Other wise you may face abend at UNPK instruction. |
Unless you have an addressability error or one (or both) of the operand lengths is screwy, then you will never get an error on an UNPK.
If all is OK, you can UNPK any data type....
Regards, |
|
Back to top |
|
|
Harsh Pawar
New User
Joined: 04 Jun 2008 Posts: 25 Location: Noida
|
|
|
|
I think Bill is right "If all is OK, you can UNPK any data type.... "
I was getting expected result when i used EX with MVC and TRT (without doing SLL Reg,4) so i got confused when i used it the same way with UNPCK.
Actually i missed that MVC and TRT are SS1 type instruction and hence moving the length into register's last byte's last 4 bit will work i.e. (R08=0005 worked).
But UNPCK is SS2 type intruction and we need to take care of both Op1 and Op2's length hence we need to move both the length into last byte of the register.
first 4 bit of last byte is length of Op1 and last 4 bit is length of Op2
Enrico, your suggestion worked and now i am getting expected output.
thank u all !!
Regards,
Harsh |
|
Back to top |
|
|
|