Don't be so modest John - that is decent, maintainable code from where I sit, 
and a fine example of what needs to be done.

Thanks for sharing.

Peter

-----Original Message-----
From: IBM Mainframe Assembler List <[email protected]> On Behalf 
Of John McKown
Sent: Tuesday, June 6, 2023 12:10 PM
To: [email protected]
Subject: Re: Calling C functions from HLASM

I really hesitate to mention this, being as it it mine, not really very good 
code, but https://github.com/JohnArchieMckown/utilities-1/find/master 

And look at SKELETON.s file. Plesse be kind. The entire program is LE enabled, 
with LE startup and termination macros, from IBM.

On Tue, Jun 6, 2023, 10:55 Rick Troth <[email protected]> wrote:

> Forgive me if you already know ...
>
> C requires a stack (at least), sometimes more for sake of minimizing 
> the surprise factor (for developers who think it's always a Unix thing).
> After that, there's not much difference (in my experience) to call a C 
> routine than to call an assembler routine.
> There's nothing in the code you got from ChatGPT which would 
> instantiate the expected stack and supplemental environment.
>
> Have you called COBOL from assembler? Similar game there, and similar 
> instantiation req (LE and whatever it has evolved into these days).
>
> I hope this helps.
>
> -- R; <><
>
>
>
> On 6/6/23 11:27, Dave Clark wrote:
> >          Would someone show me an example of calling a C function 
> > from HLASM?  I tried asking ChatGPT and got the following.  I don't 
> > see how this will link from HLASM to the C function.
> >
> >           PRINT NOGEN
> >           TITLE 'HLASM Calling ldap_open'
> >
> >           USING *,12
> >           LR 12,15
> >           LA 15,SAVEAREA
> >
> >           ENTRY START
> >
> > SAVEAREA DS 18F
> >
> > LDAP_OPEN EQU *
> >           DROP 0
> >           LR 15,13
> >           BALR 14,15
> >           USING LDAP_OPEN,14
> >           DROP 1
> >           L 1,LDAP_HOSTNAME
> >           L 2,LDAP_PORT
> >           L 3,LDAP_RESULT
> >           BALR 14,15
> >           USING LDAP_OPEN,14
> >           DROP 0
> >           L 15,SAVEAREA
> >           RETURN (14,12),RC=0
> >
> > START    DS 0H
> >           ...
> >           ... ; HLASM code
> >           ...
> >           LA 1,LDAP_HOSTNAME
> >           LA 2,LDAP_PORT
> >           LA 3,LDAP_RESULT
> >           BALR 14,15
> >           USING LDAP_OPEN,14
> >           ...
> >           ... ; Continue with HLASM code
> >           ...
> >           PRINT NOGEN
> >           END START
> >
> > Sincerely,
> >
> > Dave Clark
>

This message and any attachments are intended only for the use of the addressee 
and may contain information that is privileged and confidential. If the reader 
of the message is not the intended recipient or an authorized representative of 
the intended recipient, you are hereby notified that any dissemination of this 
communication is strictly prohibited. If you have received this communication 
in error, please notify us immediately by e-mail and delete the message and any 
attachments from your system.

Reply via email to