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

Reply via email to