I know how to branch to the subroutine using BAL. How do I pass input/output parameters (either character or packed decimal) between the subroutine and main program in assembler language?
Joined: 03 Dec 2002 Posts: 579 Topics: 1 Location: Iowa, USA
Posted: Fri May 23, 2008 3:00 pm Post subject:
You should follow the standard linkage conventions. Before the BAL, set up your parameter list, store the address of the list into a fullword and load the address of that fullword into Register 1.
The first halfword in the parameter list is typically the length of the parameter list.
You might let the subroutine update the parameter list you send it or you can repeat the process prior to returning and the main programs can find the return parm from Reg 1. _________________ Regards,
Bill Dennis
Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity.
Bill,
I read similiar instructions in an old assembler programming book. Unfortunally, it doesn't provide sample codes. I will be helpful if there are some sample codes to look at.
The book mentioned contruct an address list and load the address list to a register (e.g. register 1) priot to calling the subroutine:
Code:
ADDRLST1 DC A(Q1_Inp1)
A(Q1_Inp2)
A(Q1_Inp3)
A(Q1_Out1)
A(Q1_Out2)
A(Q1_Out3)
A(Q1_Out4)
LA 1,ADDRLST1
BAL 5,MYFUNC
Here are some of the questions:
Code:
1. If I call the subroutine 3 times with different parameter list, do I need to set up 3 address lists (i.e. ADDRLST2 for Q2_XXX, ADDRLST3 for Q3_XXX)
2. Once inside the subroutine, how do I assgin the value from the address list (1st one to Inp1, 2nd to Inp2..6th to Out3 etc.)? I want to be able to reference the variables by names in the subroutine, i.e. Inp1, Inp2...Out3.
Joined: 03 Dec 2002 Posts: 579 Topics: 1 Location: Iowa, USA
Posted: Tue May 27, 2008 12:37 pm Post subject:
Three separate parm lists would be the least complicated. Just point R1 at the proper list prior to the call.
Are the areas (Q1_INP1 ,Q1_INP2, etc) contiguous in storage? I mean could you only pass one address being the start of the area?
In the subroutine, store the parm list pointer in R1 into another register/fullword, load the desired address from the list into a register and set up a USING on that reg to a dsect describing that area. _________________ Regards,
Bill Dennis
Disclaimer: My comments on this foorum are my own and do not represent the opinions or suggestions of any other person or business entity.
No, input parameters (Q1_INP1, Q1_INP2 etc.) are not contiguous in storage, but the output parameters (Q1_OUT1, Q1_OUT2 etc.) are contiguous. I am not familiar with DSECT and will try to look it up.
No, input parameters (Q1_INP1, Q1_INP2 etc.) are not contiguous in storage, but the output parameters (Q1_OUT1, Q1_OUT2 etc.) are contiguous. I am not familiar with DSECT and will try to look it up.
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