It depends to some extent on how much you want to learn about C and LE
linkage conventions. If the answer is "nothing at all - I just want it to
work", then you might want to try inserting a
#pragma linkage(rxhlicpl,OS)
which tells the compiler to use an OS-style argument list when it calls
your function.

Or... If you want to learn a bit, try writing a little dummy C program that
expects the same data structure your are using in assembler. Put in at
least some code that acts on both the input and output values in your
DSECT. Compile both the C caller and the C subroutine and look at the
generated assembler code to see what it does. By default this will be
using the standard C linkage, and you can model your assembler code on that.

By default the generated assembler listing is not real assembler code, but
a syntactically similar pseudo assembler code that gives you general idea
of what the real assembler code would be. It does show you the true
generated machine code, however.

Tony H.

On Tue, 16 Apr 2024 at 12:19, Willy Jensen <willy.h.jen...@outlook.com>
wrote:

> Anybody have a sample of how to return a fullword to a C program from an
> assembler subroutine?
> Apologies if this seems basic, but I really haven't looked seriously at C
> before.
> I have read about 'Combining C or C++ and Assembler programs', which
> didn't help.
>
> I have this C program (extract):
>  extern int rxhlicpl();
>  int retcode;
>  char hlicmd[8];
>  char name[61];
>  int  namelen;
>  char text[121];
>  int  textlen;
> . . .
>  strcpy (hlicmd, "VGET    ");
>  strcpy (name, "TESTVAR");
>  namelen = 7 ;
>  strcpy (text, " ");
>  textlen = 120;
>  retcode = rxhlicpl (hlicmd, name, namelen, text, textlen);
>  printf("rc is %d, text is %d '%s'\n\n", retcode, textlen, text);
>
> Running the program shows: rc is 0, text is 120 'Kilroy was here yesterday'
>
> The RXHLICPL program is an assembler subroutine which returns data to the
> C program. The char field is updated, but not the int field. I know from
> tracing the assembler subroutine that the length value is correct and not
> 120.
> The same subroutine, except from setting the end-of-data char in the text
> area, runs in COBOL and sets the textlen field correctly.
> I assume that it has something to do with C pointers, I never could get my
> head around those.
>
> The assembler pgm (extract):
>
> ndp_blk    dsect
> ndp_cmda   ds   a
> ndp_namea  ds   a
> ndp_namela ds   a
> ndp_texta  ds   a
> ndp_textla ds   a
>
>          ereg  0,1
>          lr    r9,r1
>          using ndp_blk,r9
>          l     r5,zrx_getdl            data size
>          l     r1,ndp_textla           -> data length field
>          st    r5,0(,r1)
>
> I am not using the the prolog and epilog macros as it seemed to work
> without, and I really would like to avoid LE.
>
> ----------------------------------------------------------------------
> For IBM-MAIN subscribe / signoff / archive access instructions,
> send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to lists...@listserv.ua.edu with the message: INFO IBM-MAIN

Reply via email to