OS/VS PL/I and assembler functions? 
Author Message
 OS/VS PL/I and assembler functions?

Hi, there!

Has anybody any idea, how to get OS/VS PL/I  using an assembler sub-routine
like a PL/I-function?
I intend to do something like

... DCL getCntr EXTERNAL ENTRY( CHAR(7) )
                                  OPTIONS( ASM INTER ) RETURNS( BIN
FIXED(15,0) ); ...

... intCounter = getCntr( "TEST" ); ...

where  getCntr  is written in assembler language (due to performance and
interoperability considerations)

My first try gave me a nice "COBOL or ASSEMBLER will not be invoked as
function"-message - so, is there a way to do it anyway?

bye
Alexander



Tue, 24 Apr 2001 03:00:00 GMT  
 OS/VS PL/I and assembler functions?

Quote:

> Has anybody any idea, how to get OS/VS PL/I  using an assembler sub-routine
> like a PL/I-function?  I intend to do something like

> .... DCL getCntr EXTERNAL ENTRY( CHAR(7) )
>            OPTIONS( ASM INTER ) RETURNS( BIN FIXED(15,0) ); ...
> .... intCounter = getCntr( "TEST" ); ...

Change it to become:
      DCL getCntr EXTERNAL ENTRY( CHAR(7) , BIN FIXED(15,0))
             OPTIONS( ASM INTER ) ;
      CALL  getCntr( 'TEST',intCounter);

Quote:
> where  getCntr  is written in assembler language
> (due to performance and interoperability considerations)
> My first try gave me a nice "COBOL or ASSEMBLER will
> not be invoked as function"-message - so, is there a way to do it anyway?

Change the Assembly-language code to accept *TWO* parameters,
and to return the result via the second parameter.
This can be done at the "exit" of the routine, i.e.,

      L  R14,12(,R13)         Restore R14, and do *NOT* restore R0.
      LM R1,R12,24(R13)    Restore R1 through R12.
      LM R1,4(,R1)               Get addres of 2nd parameter.
      STH R0,0(,R1)            Store function-result into FIXED
BIN(15).
      BR   R14                Return to caller, with R2 through R14
the same as upon entry.
* PL/I does not require that R15, R0, and R1 be unmodified.

Or, remove the 'OPTIONS' from the 'DCL'.
PL/I will then generate a call with two arguments.
The Assembly-language routine will have to handle the extra-level
of "indirection" (the first argument will point to a descriptor of the
CHAR variable,
rather than pointing to the first byte of the CHAR variable),
and will have to handle the presence of the 2nd parameter, as above.

Since a PL/I function can return non-integer and non-floating results,
any "function-call" in PL/I internally becomes a subroutine-call,
with N+1 parameters.



Wed, 25 Apr 2001 03:00:00 GMT  
 OS/VS PL/I and assembler functions?
Hi, group and hi, Melvin!

Sorry for answering in the discussion group, but maybe the following is an
important refinement of my question.

Melvin answered:

Quote:
>> Change the Assembly-language code to accept *TWO* parameters,

Well - that would be the simple solution for the example - but I intend to
use the function result as parameter for another proceudre (something like
... CALL MyProc( 3, getCntr( "TEST" ) ); ... and so on).
So, two parameters don't get me to heaven ...
But maybe Melvins comment:
Quote:
>> Or, remove the 'OPTIONS' from the 'DCL'. PL/I will then generate a call
with two arguments.
>> The Assembly-language routine will have to handle the extra-level of

"indirection" (the first
Quote:
>> argument will point to a descriptor of the CHAR variable, rather than

pointing to the first byte
Quote:
>> of the CHAR variable), and will have to handle the presence of the 2nd

parameter, as above.
is it - I think I'll give it a try on monday ....

Thank you
Alex



Wed, 25 Apr 2001 03:00:00 GMT  
 OS/VS PL/I and assembler functions?

 on Fri, 6 Nov 1998 19:49:03 +0100,

Quote:
>Hi, there!

>Has anybody any idea, how to get OS/VS PL/I  using an assembler sub-routine
>like a PL/I-function?
>I intend to do something like

>... DCL getCntr EXTERNAL ENTRY( CHAR(7) )
>                                  OPTIONS( ASM INTER ) RETURNS( BIN
>FIXED(15,0) ); ...

>... intCounter = getCntr( "TEST" ); ...

>where  getCntr  is written in assembler language (due to performance and
>interoperability considerations)

>My first try gave me a nice "COBOL or ASSEMBLER will not be invoked as
>function"-message - so, is there a way to do it anyway?

>bye
>Alexander

Alexander,
 the PL/I compiler for the IBM S/390 system does not permit a function
 coded in Cobol or Assembler to be called as a PL/I function, as you have
 it in your example. There are two ways around this problem:

     1) change the function to be something like this:
         DCL getCntr Entry (Char(7), Fixed Bin(15)) Options(Asm, Inter);
         Call getCntr('TEST',intCounter);
           ...in other words, change it from a function to a subroutine.

 or
     2) code the Assembler getCntr function to mimic what a real PL/I
        functions does. You can find out the calling conventions for
        PL/I functions in the Programmers Guide, I believe. Then your
        declare would just be:
           DCL getCntr Entry(Char(7)) Returns(Fixed Bin(15));

Dave Jones



Wed, 25 Apr 2001 03:00:00 GMT  
 OS/VS PL/I and assembler functions?

Quote:

> Has anybody any idea, how to get OS/VS PL/I  using an assembler sub-routine
> like a PL/I-function?
> I intend to do something like

> ... DCL getCntr EXTERNAL ENTRY( CHAR(7) )
>                                   OPTIONS( ASM INTER ) RETURNS( BIN
> FIXED(15,0) ); ...

> ... intCounter = getCntr( "TEST" ); ...

> where  getCntr  is written in assembler language (due to performance and
> interoperability considerations)

I've done a lot of this and have a few helper macros to mimic the PL/I
linkage.  The current incarnation supports PL/I for MVS & VM version 1.
Write me offline if you're interested.


Fri, 27 Apr 2001 03:00:00 GMT  
 OS/VS PL/I and assembler functions?
How about putting your non-PL/I subroutine within a PL/I wrapper to turn it
into a function that can be called from PL/I:
---------------------------------------
PROG1:  PROC;
DCL MYFUNC EXTERNAL;
. . .
IF MYFUNC(parms) THEN . . .
. . .
END PROG1;
--------------------------------------------
MYFUNC:  PROC(RETVAL, parms);
/* This routine transforms the MYSUB subroutine into a function by converting
a    */
/* parameter into a return value.  */
DCL MYSUB EXTERNAL ENTRY OPTIONS(ASM . . .);
DCL RETVAL . . . ;
CALL MYSUB(RETVAL, parms);
RETURN RETVAL;
END MYFUNC;
--------------------------------------------
Quote:

> Hi, group and hi, Melvin!

> Sorry for answering in the discussion group, but maybe the following is an
> important refinement of my question.

> Melvin answered:

> >> Change the Assembly-language code to accept *TWO* parameters,

> Well - that would be the simple solution for the example - but I intend to
> use the function result as parameter for another proceudre (something like
> ... CALL MyProc( 3, getCntr( "TEST" ) ); ... and so on).
> So, two parameters don't get me to heaven ...
> But maybe Melvins comment:
> >> Or, remove the 'OPTIONS' from the 'DCL'. PL/I will then generate a call
> with two arguments.
> >> The Assembly-language routine will have to handle the extra-level of
> "indirection" (the first
> >> argument will point to a descriptor of the CHAR variable, rather than
> pointing to the first byte
> >> of the CHAR variable), and will have to handle the presence of the 2nd
> parameter, as above.
> is it - I think I'll give it a try on monday ....

> Thank you
> Alex



Fri, 04 May 2001 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. Migrating from OS/VS PL/I to VA PL/I

2. What is the difference between DEC PL/1 and OS/390 PL/1

3. VisualAge PL/I for OS/390 and PL/I 2.3

4. pl/1 vs. PL/I

5. PL/I vs. PL/1

6. OS/VS COBOL and z/OS Version 1 Release 3

7. z/OS Version 1 Release 3 and OS/VS COBOL

8. os.popen() vs os.system()

9. os/vs cobol vs cobol II

10. VS COBOL II vs. OS/390

11. New CICS removes Translator support for VS COBOL II (and OS/VS COBOL)

12. OS/VS COBOL to VS COBOL II

 

 
Powered by phpBB® Forum Software