View previous topic :: View next topic
|
Author |
Message |
vinayknj
New User
Joined: 26 May 2008 Posts: 50 Location: Bangalore
|
|
|
|
Hi,
I have written below code to understand the concept of DSECT and establishing addressability for DSECT.
But the compilation error says No Active USING for the fields under DSECT(OPERTNA,ADD1A,ADD2A).
Code: |
TESTPGM2 START
SAVE (14,12)
USING *,R5
BALR R5,R0
BCTR R5,R0
BCTR R5,R0
OPEN (OUTFLE,OUTPUT)
ADDIT MVC OPERTN,=C'ADD'
L R2,ADD1
AH R2,ADD2
CHI R2,50
BE ADDSUC
WTO 'FAIL:ADDITION(AH) OF X''31 WITH X''14 IS NOT X''45'''
B DISP
ADDSUC WTO 'SUCC:ADDITION(AH) OF X''31 WITH X''14 IS X''45'''
DISP LA R3,RESULT
ST R2,0(R3)
PUT OUTFLE,ADDDATE
WTO '***DSECT AND ADDRESSABILITY***'
ADD USING ADDFLD,R9
L R9,OUTREC
MVC OPERTNA,=C'ADD'
L R2,ADD1A
MVI ADD2A,10
AH R2,ADD2A
CHI R2,40
BE ADDSUC
WTO 'FAIL:ADDITION(AH) OF 30 WITH 10 IS NOT 40'
B DISP
ADDSUC2 WTO 'SUCC:ADDITION(AH) OF 30 WITH 10 IS 40'
DISP2 LA R3,RESULTA
ST R2,0(R3)
PUT OUTFLE,OUTREC
CLOSE OUTFLE
* DATA FIELDS FOR AH INSTRUCTION
ADDDATE DC 0CL80
OPERTN DC CL3' '
FILLER1 DC C' '
ADD1 DC F'30'
FILLER2 DC C' '
ADD2 DC H'20'
FILLER3 DC C' '
RESULT DC F'0'
FILLER4 DC CL64' '
OUTREC DC CL80' '
OUTFLE DCB DSORG=PS, X
MACRF=(PM), X
DDNAME=OUTFILE, X
LRECL=80, X
RECFM=FB, X
SYNAD=ERROR1, X
BLKSIZE=8000
ADDFLD DSECT
OPERTNA DC CL3' '
FILLER1A DC C' '
ADD1A DC F'30'
FILLER2A DC C' '
ADD2A DC H'20'
FILLER3A DC C' '
RESULTA DC F'0'
FILLER4A DC CL64' '
*
END |
But the compilation error says No Active USING for the fields under DSECT(OPERTNA,ADD1A,ADD2A).
Please let me know what is wrong with the code. Thanks |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8700 Location: Dubuque, Iowa, USA
|
|
|
|
You have to allocate memory pointed to by a register, then issue a USING ADDFLD,register to make the DSECT variables usable -- BEFORE using any of the variables. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
First of all, get rid of those two consecutive BCTR's. What are they for?
Second, I don't see a USING and an associated base-register for the ADDFLD DSECT.
DSECT's belong at the top, before the start of the CSECT, but that has nothing to do with the USING error.
Issue a GETMAIN and then load R9 (as an example DSECT base) from R1 with the address, followed by USING ADDFLD,R9. You're also missing an 18-Word Register-Savearea (standard practice) and the RETURN Macro with an accompanying R15.
Bill |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
Quote: |
DSECT's belong at the top, before the start of the CSECT |
Not at my shop. Every in-house Assembler application has the DSECTs at the bottom. I think it's according to taste...
Garry. |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
You are using a labeled USING so you would need someting like :
MVC ADD.OPERTNA,=C'ADD'
better is :
ADD EQU *
USING ADDFLD,R9
And for the rest your coding sucks big time. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Garry,
HLASM recommends placing the DSECTS at the top. This is just the opposite of its predecessors.
DSECTS at the top prevent the Assembler from "Double Sweeping" during Assembly.
Bill |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
Something else. Move the BALR R5,R0 to just after the SAVE Macro, then followed by the USING for the CSECT.
Change L R9,OUTREC to LA R9,OUTREC
Bill |
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
Code: |
ADDFLD DSECT
OPERTNA DC CL3' '
FILLER1A DC C' '
ADD1A DC F'30'
FILLER2A DC C' '
ADD2A DC H'20'
FILLER3A DC C' '
RESULTA DC F'0'
FILLER4A DC CL64' ' |
Shouldn't all DC's be DS's here? I believe that DSECT acts just as a "stencil" over a data area and does nothing like initialising that area. |
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
Code: |
BCTR R5,R0
BCTR R5,R0 |
A different way of adjusting the address in base register.
I once placed a BALR after USING and it took me quite long to detect the problem. |
|
Back to top |
|
|
Garry Carroll
Senior Member
Joined: 08 May 2006 Posts: 1205 Location: Dublin, Ireland
|
|
|
|
Quote: |
A distinct way of adjusting the base register address.
|
No, an unconventional way. Most would
Code: |
TESTPGM2 CSECT
L R5,R15
USING TESTPGM2,R5 |
Garry. |
|
Back to top |
|
|
nigelosberry
New User
Joined: 06 Jan 2009 Posts: 88 Location: Ggn, IN
|
|
|
|
Garry Carroll wrote: |
Quote: |
A distinct way of adjusting the base register address.
|
No, an unconventional way. Most would
Code: |
TESTPGM2 CSECT
L R5,R15
USING TESTPGM2,R5 |
Garry. |
Yes. absolutely!
One should not reach a point wherein one has to adjust the content of base. |
|
Back to top |
|
|
vinayknj
New User
Joined: 26 May 2008 Posts: 50 Location: Bangalore
|
|
|
|
Thanks everyone. The issue is resolved, as mentioned by Peter I would have to use ADD.OPERTNA. |
|
Back to top |
|
|
|