Hi,
I am trying to use the below instruction to initialize one of the packed decimal field during processing inside an assembler program.
ZAP TEMPNUM,ZEROES
where TEMPNUM and ZEROES are declared as below.
TEMPNUM DC PL2'0'
ZEROES DC PL2'0'
TEMPNUM is being used in few calculations in the program but ZEROES remain the same throughout.
However my TEMPNUM is not getting initialised to zeroes on using the ZAP instruction.
I also tried using the SP instruction like below
SP TEMPNUM,TEMPNUM to move zeroes but I can see that TEMPNUM still has some values inside it.
Could you let me know if there is anything missing?
Thank you.
Unable to initialize packed decimal using ZAP/SP instruction
-
- Global moderator
- Posts: 3720
- Joined: Sat Dec 19, 2009 8:32 pm
- Skillset: Systems programming, SAS, COBOL, CICS, JCL, SMS, VSAM, etc.
- Referer: other forum
- Location: Dubuque, Iowa, USA
Re: Unable to initialize packed decimal using ZAP/SP instruc
What values? And how are you looking to see that TEMPNUM "has some values inside it"?but I can see that TEMPNUM still has some values inside it.
Could you let me know if there is anything missing?
And why do you think that you are the first person, in all the many thousands of people to use the ZAP instruction over the last many years, to have it perform incorrectly? It is vastly more likely that you are either misinterpreting the value, or you are misrepresenting what you are doing.
Re: Unable to initialize packed decimal using ZAP/SP instruc
Hi Robert,
I used the below lines of code to check the value in TEMPNUM.
So, when my program abends, register 6 should have shown zeroes. Instead it is showing 295C which was the value of TEMPNUM computed in one of the previous steps. That is how I determined that TEMPNUM is not getting initialised to zeroes.
I used the below lines of code to check the value in TEMPNUM.
Code: Select all
ZAP TEMPNUM,ZEROES
L 6,TEMPNUM
WTO 'DISPLAY5'
DC H'0' ABEND PROGRAM
So, when my program abends, register 6 should have shown zeroes. Instead it is showing 295C which was the value of TEMPNUM computed in one of the previous steps. That is how I determined that TEMPNUM is not getting initialised to zeroes.
Code: Select all
PSW AT TIME OF ERROR 078D0000 00007DCC ILC 2 INTC 01
ACTIVE LOAD MODULE ADDRESS=00007C40 OFFSET=0000018C
NAME=STUDEG
DATA AT PSW 00007DC6 - E8F50A23 000047F0 C0204510
GR 0: 00000000_00011000 1: 00000000_00A9AC73
2: 00000000_00000040 3: 00000000_007DA9D4
4: 00000000_007DA9B0 5: 00000000_007FF510
6: 00000000_000C295C 7: 00000000_FD000000
8: 00000000_007DCD30 9: 00000000_007FF7D0
A: 00000000_00000000 B: 00000000_007FF510
C: 00000000_40007C46 D: 00000000_00007F64
E: 00000000_50007DAC F: 00000010_00000000
END OF SYMPTOM DUMP
-
- Global moderator
- Posts: 3805
- Joined: Tue Jan 25, 2011 12:02 am
- Skillset: Easytrieve Plus, Cobol, Utilities, that sort of stuff
- Referer: Google
Re: Unable to initialize packed decimal using ZAP/SP instruc
The length of your field is two bytes, a half-word happens to be that long. L(oad) operates on Words, four bytes long. You have loaded four bytes starting at the address of TEMPNUM. If you look at the first two bytes of Register six, you'll see your X'000C', then then value which just happens to be two bytes to the right of TEMPNUM.
If you want to only put two bytes in a register, LH (Load Halfword) can do it.
If you want to only put two bytes in a register, LH (Load Halfword) can do it.
-
- Posts: 9
- Joined: Tue Jan 17, 2017 1:36 pm
- Skillset: Cobol,JCL,Assembler
- Referer: Through online
Re: Unable to initialize packed decimal using ZAP/SP instruc
Load will move the 4 byte data from storage to register. And TEMPNUM PL2'0' will occupy only 2 bytes. That means if you try to move the Tempnum to register 6 first two bytes will have the data of tempnum and next two bytes will have the data at the address tempnum+2 and tempnum+3.
"6: 00000000_000C295C" In this 000c is the data present in the tempnum
Correct me if i'm wrong.
"6: 00000000_000C295C" In this 000c is the data present in the tempnum
Correct me if i'm wrong.
-
- Global moderator
- Posts: 2105
- Joined: Thu Jun 03, 2010 6:21 pm
- Skillset: Assembler, JCL, utilities
- Referer: zos.efglobe.com
Re: Unable to initialize packed decimal using ZAP/SP instruc
From Principles of Operation - "The second operand is placed at the first-operand location. The operation is equivalent to an addition to zero. The operand and result are in the packed format."
The second sentence effectively says TEMPNUM is set to a packed decimal 0 - 000C, and then the contents of ZEROES, presumably 000C, is added to it.
monica1 - You have got to learn, much better than you seem to understand now -
The second sentence effectively says TEMPNUM is set to a packed decimal 0 - 000C, and then the contents of ZEROES, presumably 000C, is added to it.
monica1 - You have got to learn, much better than you seem to understand now -
- Exactly how packed decimal values are represented in storage.
- How to use and understand the Assembler listing.This is telling you that ZEROES is 000C.
Code: Select all
Loc Object Code Addr1 Addr2 Stmt Source Statement
00000A 6 TEMPNUM DS PL2
00000C 000C 7 ZEROES DC PL2'0' - I'd bet you did not bother to read, much less attempt to understand, the reference I gave you a couple of days ago on the other help site. Preparing those links is somewhat involved - they are not put into a response by magic - and such blatant disregard of them makes it much less likely a responder - Billyboyo, krishnaraj6eee or me, for example, will bother to respond to your queries in the future.
- What happens when an instruction is executed.
- How to read the contents of a "dump," whether it is a more complete storage dump or the little summary dump you gave us.
-
- Global moderator
- Posts: 2105
- Joined: Thu Jun 03, 2010 6:21 pm
- Skillset: Assembler, JCL, utilities
- Referer: zos.efglobe.com
Re: Unable to initialize packed decimal using ZAP/SP instruc
monica1 wrote:... I also tried using the SP instruction like below
SP TEMPNUM,TEMPNUM to move zeroes but I can see that TEMPNUM still has some values inside it.
Could you let me know if there is anything missing?
Thank you.
The problem with
SP TEMPNUM,TEMPNUM
is what if the contents of TEMPNUM is not a packed decimal number? The definition of the SP instruction is both operands must be a packed decimal number, and it will fail if the contents of both operands are not packed decimal.
ZAP TEMPNUM,ZEROS
TEMPNUM DS PL2
ZEROS DC P'0'
requires that the contents of ZEROS must be packed decimal.
To test your idea, I wrote this program -
Code: Select all
SP CSECT
USING *,15
SP NUM1,NUM1
SP NUM2,NUM2
SR 15,15
BR 14
NUM1 DC P'-999'
NUM2 DC P'999'
END SP
I then run it using TSO TEST
This is the session log -
Code: Select all
test sp
TEST
l (num1 num2) x
NUM1 999D
NUM2 999C
TEST
go
PROGRAM UNDER TEST HAS TERMINATED NORMALLY+
TEST
l (num1 num2) x
NUM1 000C
NUM2 000C
The LIST (L) command is quite flexible. It will normally convert numerics to printable decimal. Here I told it to list the data as hexadecimal.
Code: Select all
test sp
TEST
l (num1 num2)
NUM1 -999
NUM2 +999
TEST
Re: Unable to initialize packed decimal using ZAP/SP instruc
Thank you very much for all your help.
I was able to resolve my issue. This piece of code which I was trying to initialize was inside a loop and towards the end of a loop due to an incorrect instruction, values from another variable were being populated into TEMPNUM.
Once that instruction was corrected, the issue got resolved.
Thanks again everyone.
I was able to resolve my issue. This piece of code which I was trying to initialize was inside a loop and towards the end of a loop due to an incorrect instruction, values from another variable were being populated into TEMPNUM.
Once that instruction was corrected, the issue got resolved.
Thanks again everyone.
-
- Similar Topics
- Replies
- Views
- Last post
-
- 2
- 4142
-
by sergeyken
View the latest post
Tue Aug 02, 2022 4:07 am
-
-
Array processing and Table handling with packed decimal
by rogerstrycova » Tue Oct 26, 2021 3:55 pm » in IBM Cobol - 2
- 1726
-
by Robert Sample
View the latest post
Wed Oct 27, 2021 1:12 am
-
-
- 1
- 4433
-
by TERMEN
View the latest post
Thu Mar 04, 2021 2:29 am
-
- 6
- 2615
-
by sergeyken
View the latest post
Wed Nov 24, 2021 11:26 pm
-
-
How to sum a decimal value using sort
by hkaur7087 » Thu Aug 05, 2021 2:19 pm » in DFSORT/ICETOOL/ICEGENER - 4
- 2366
-
by sergeyken
View the latest post
Thu Aug 05, 2021 7:48 pm
-