Page 2 of 2

Re: Invoking Sort from assembler

PostPosted: Fri Jul 27, 2012 12:22 pm
by sensuixel
BillyBoyo wrote:
ASMSRCT2 CSECT                                                 
         INITL 12,EQU=R      BASE REG = 12, R15 = 15   
OPEN_FIC EQU  *                                               
         OPEN   (SORTIN,(INPUT))                               
         OPEN   (SORTOUT,(OUTPUT))                             
         LA      R1,PARLST LOAD ADDR OF PARAM POINTER IN R1   
         LINK    EP=SORT                                       
ENDFIC   CLOSE   SORTIN                                       
         CLOSE   SORTOUT 


It was the above that "threw" me :-)

sensuixel,

This is the latest DFSORT Application Programming Guide (ice1ca60), if your DFSORT is up-to-date.


The first part of my code (OPEN and CLOSE phase) come from an another program i'm working on, where I need to compare LRECL of INPUT and OUTPUT data set.

My first intention was to test the SORT part separately then bring back the code in my main program. ;)

Anyway thanks a lot for all your replies and for the updated documentation.

When i said "guess" I didn't mean to be rude, sorry if it was interpreted that way. ;)

Re: Invoking Sort from assembler

PostPosted: Fri Jul 27, 2012 7:44 pm
by dick scherrer
Hello,

When i said "guess" I didn't mean to be rude, sorry if it was interpreted that way.
We encounter many misunderstood communications here - not to worry - we eventually get it right :)

Re: Invoking Sort from assembler

PostPosted: Fri Jul 27, 2012 8:35 pm
by steve-myers
Just a comment on style, not really substance.

You did
         LA    1,PARLIST
         LINK  EP=SORT

This works perfectly well, but you made two assumptions - safe assumptions as it happens, but still assumptions.
  1. The LINK macro uses register 1 to pass a parameter list to the load module it is linking to
  2. The LINK macro does not modify register 1
Actually, the LINK macro has two parameter lists.
  • The parameter list sent to the new program.
  • A parameter list the LINK service uses
An experienced programmer uses code like this -
         LINK  EP=SORT,MF=(E,PARLIST)
The LINK macro loads the address of the parameter list into register 1 just as you did. Many programmers do it this way -
         LA    1,PARLIST
         LINK  EP=SORT,MF=(E,(1))

Arguably this is safer because you are doing two things.
  • You are telling the LINK macro the parameter list address is in register 1 AND
  • Don't modify register 1
Now I don't like in line parameter lists, so I frequently write
         LA    1,PARLIST
         LINK  EP=SORT,MF=(E,(1)),SF=(E,LINKPARM)
         ...
LINKPARM LINK  SF=L,EP=SORT

Re: Invoking Sort from assembler

PostPosted: Sat Jul 28, 2012 7:19 pm
by steve-myers
I just looked at my last post, and realized my no inline parameter list was all wrong. What I really want is something like this -
         LINK  SF=(E,LINKPARM),MF=(E,PARMLIST)
         ...
LINKPARM LINK  SF=L,EP=SORT
PARMLIST CALL  ,(...),VL,MF=L
Actually, PARMLIST is not right for sort , but it is more or less correct as a generic call.