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 

Addressability issue on BALR while using USING <csect-nam

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


Joined: 07 Nov 2008
Posts: 9
Topics: 6

PostPosted: Thu Nov 19, 2009 6:25 am    Post subject: Addressability issue on BALR while using USING <csect-nam Reply with quote

I tried to establish addressability for a CSECT from its origin(USING BALRTEST,R12), rather than the current location(USING *,R12). But the program abended with S0C1 when branching to sub program using BALR.

Below code abended with S0C1 at X'12' BALR R14,R15. But the sub program was called without any error when I use USING *,R12.

Code:
000000 90EC D00C            0000C    21          STM   R14,R12,12(R13)
000004 05C0                          22          BALR  R12,0
                 R:C  00000          23          USING BALRTEST,R12
000006 50D0 C024            00024    24          ST    R13,SAVE+4
00000A 41D0 C020            00020    25          LA    R13,SAVE
00000E 58F0 C068            00068    27          L     R15,VSUB
000012 05EF                          28          BALR  R14,R15
000014 58D0 C024            00024    30 RETURN   L     R13,SAVE+4
000018 98EC D00C            0000C    31          LM    R14,R12,12(R13)
00001C 1BFF                          32          SR    R15,R15
00001E 07FE                          33          BR    R14
000020                               35 SAVE     DS    18F
000068 00000000                      36 VSUB     DC    V(SUB)
000000                               37          END   BALRTEST

I suspect, address of SUB was not assigned to VSUB properly. Can any one please clarify this?
Back to top
View user's profile Send private message Send e-mail
RonB
Beginner


Joined: 02 Dec 2002
Posts: 93
Topics: 0
Location: Orlando, FL

PostPosted: Thu Nov 19, 2009 7:49 am    Post subject: Reply with quote

According to the expansion, the L R15,VSUB becomes 58F0 C068 ( namely Load R15 with the address of Register 12 + an offset of x'68' ). According to the expansion, VSUB is located at offset 68. SO. . .if the content of R12 was ZERO, the L R15,VSUB would load the value of R12 ( Zero ) + an offset of x'68', and all would be well.
However, when you do a BALR R12,0 at offset 4, and then a USING BALRTEST,R12, you set the value of R12 to +4, NOT ZERO. So your L R15,VSUB now translates to loading the value of R12 ( +4 ) + x'68' and you get an invalid address for the following BALR R14,R15.
When you do it the RIGHT way, R12 contains a value of +4 as well, BUT the offsets are then made off of THAT value, not the CSECT start address ( namely, if you look at the expansion you will see that the offset of VSUB will be +64, not +68 ).

Hope that helps.
_________________
A computer once beat me at chess, but it was no match for me at kick boxing.
Back to top
View user's profile Send private message
RonB
Beginner


Joined: 02 Dec 2002
Posts: 93
Topics: 0
Location: Orlando, FL

PostPosted: Thu Nov 19, 2009 9:17 am    Post subject: Reply with quote

After thinking about what I wrote, I realize that it may sound like I said that the offset of the DC statement for VSUB would show as 000064 instead of 000068. That isn't true. The offset of the DC for VSUB will still show as 000068 - but the expansion of the L R15,VSUB will show 58F0 C064 instead of 58F0 C068.
Also, I didn't mean to imply that there is only ONE "right" way. Any way is "right" code-wise, as long as your USING statement and the address loaded into the Register being USED are in sync. With the "problem" code, you could have said USING BALRTEST+4,R12 and things would have worked OK, since the address in R12 would be the same as BALRTEST+4.
I, myself, normally code such that my Base Register is always aligned with MYCSECT base by loading the Base Register from R15 ( which is supposed to always contain the address of the entry point ), thusly:
Code:
         STM R14,R12,12(R13)
         LR  R12,R15
         USING R12,MYCSECT

Sorry if I caused any confusion ( or are making it worse with this "clarification" ) Confused
_________________
A computer once beat me at chess, but it was no match for me at kick boxing.
Back to top
View user's profile Send private message
mkusamy
Beginner


Joined: 07 Nov 2008
Posts: 9
Topics: 6

PostPosted: Fri Nov 20, 2009 4:23 am    Post subject: Reply with quote

Thanks.. I got my mistake.
Base register should have been aligned with the CSECT base. I was little careless Sad

Addressability for SAVE also not correct here, but it was not flagged as error because SAVE+4 at offset 6 is actually referring to SAVE+10.
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