gokuldass
New User
Joined: 18 Mar 2005 Posts: 48 Location: india
|
|
|
|
Hello Guys,
I have to write an assembler program which gets two parameters for eg. Name and address. Name is 10 character and address is 20 characters. Now I have to accept this two parameters and then I have to write the output to a file. How to do this ?
Also, How to identify the number of incoming parameters to an assembler program?
Please let me know if you need any clarification on my question.
Thanks in advance.
Regards,
Gokuldass |
|
kamran
New User
Joined: 01 May 2005 Posts: 55
|
|
|
|
Hi,
Depending on calling procedure input data have different format. eg. if you call your program directly with jcl and passing data to it through PARM filed of EXEC statement,upon entering to your program register 1 contains the address of input parm such that it's first two byte(half word) contains the length of input parm.So you can pass both the Name and address with parm field and define a dsect in your program to use them.
under tso the logic is the same except that register 1 contains address of a structure which is listed bellow:
first: a half word contains overall parm length including command(program name) and input parm +4.
second: a half word contains command(program name) length.
third:a string with length equal second half word containing command name.
forth: a string which contains the actual passed parm which it's length can be calculated upon previous information.
Anyhow as I can guess you are trying to call your program from another.In these cases again it depends on the calling program that how it arranged passing parameter.in most cases when there is multiple parameters passed to a program upon entrance to called program register 1 contains address of sequences of addresses which those point to each parameter.
at final it depends on the way which the parameters arranged in calling program but all of them pass an addresses to called program through general register 1.
you can explain your requirement specifically if you need more help.
one way to show number of parameter to called program is to pass a null word at end of the parameter addresses chain with high bit on. |
|
UmeySan
Active Member
Joined: 22 Aug 2006 Posts: 771 Location: Germany
|
|
|
|
Hi !
Are these parms passed by an other programm to your ass-pgm or by JCL ? The difference is, that if it's passed by JCL the number of parms are static as long as you not change the JCL. By a programm-call the numer of parms can vary, if youe design that. But this depends on your design and the things, your programm has to do.
But anyway, the adress of the adress of the parameters your getting in Register-One. The length of the parameterlist is in the first halfword.
So, if your programm gets them form JCL, here's an example
SR R3,R3 ...clean register 3
SR R5,R5 ...clean register 5
L R3,0(R1) ...load adress
LH R5,0(R3) ...load length
LTR R5,R5 ...check length zero
BZ NO_PARAMETERS
C R5,=F'30' ...check correct length of a parm-string
BNE NO_CORRECT_PARAMETERS
EX R5,GET_PARAMETERS
....store parm in pgm-field depending on length
GET_PARAMETERS MVC PARAMS,2(R3)
PARAMS DS 0CL30
PA_NAME DC CL10
PA_ADRESS DC CL20
So, if your programm gets them form another , here's an example
Parm like this: 10bytes name followed by 20bytes adress
L R1,0(R1) ....load adress of adress
L R3,0(R1) ...now load adress of parmfield (30Bytes)
MVC FIELD(30),0(R3)
or parm is like this: adress of name-field, adress of adress-field
L R1,0(R1) ....load adress of adress
L R3,0(R1) ...now load adress of parm-name (10Bytes)
L R4,4(R1) ...now load adress of parm-adress (30Bytes)
or parm is like this: adress of two adresses, first=name&second=adress
L R1,0(R1) ...load adress of adress
LM R3,R4,0(R1) ...R3 points to parm-name / R4 to parm-adress
Hope that satisfies, regards, UmeySan |
|