"IBM Mainframe Assembler List" <[email protected]> wrote on
06/06/2023 11:55:30 AM:
> 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.
I'm not a C programmer. I know some things about calling C from
RPG/ILE (in terms of null-terminated strings, etc). So, no, I did not
know that... something to learn.
> Have you called COBOL from assembler? Similar game there, and similar
> instantiation req (LE and whatever it has evolved into these days).
Yes, I have called COBOL. However, calling COBOL means you have
an up to 8-character internal name that matches an external name I can
find in the system or user library. C function names can be longer than
that and, therefore, can't possibly match anything in my system libraries.
That is the part I don't see an example of -- how to connect a C
function name to the object that would be found in the system library. In
RPG/ILE you create a procedure prototype that connects an internal RPG
procedure name to the external C function name. How do I do something
equivalent to that in HLASM?
Sincerely,
Dave Clark
--
int.ext: 91078
direct: (937) 531-6378
home: (937) 751-3300
Winsupply Group Services
3110 Kettering Boulevard
Dayton, Ohio 45439 USA
(937) 294-5331
>
> 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 email message and any attachments is for use only by the named
addressee(s) and may contain confidential, privileged and/or proprietary
information. If you have received this message in error, please
immediately notify the sender and delete and destroy the message and all
copies. All unauthorized direct or indirect use or disclosure of this
message is strictly prohibited. No right to confidentiality or privilege
is waived or lost by any error in transmission.
*********************************************************************************************