On 14 March 2014 01:51, Donald Russell <russell....@gmail.com> wrote:
> I've been looking for doc on how to do this.... It seems I need to call
> __cinit to set up a C environment, then I can call sprintf and finally
> __cterm to terminate the C environment....

I'm not sure, but the way I read it sprintf() doesn't need that
environment. The books says, in the section describing __cinit(),
"This environment is used when calling Metal C functions that require
an environment, such as those related to storage management (malloc(),
free(), and so on). "

The description of sprintf() does not mention an environment, but in
contrast that for snprintf() explicitly says "Use of snprintf()
requires that an environment has been set up by using the __cinit()
function. When the function is called, GPR 12 must contain the
environment token created by the __cinit() call."

So I would just try it with R13 pointing to a standard save area with
47KB (from Table 14 in the book) beyond the 72-byte SA, and see what
happens. Set up the SA Perhaps set R12 to zero or to a recognizably
bad address to help catch any reference to it. And you probably have
to set the NAB to point to the (duh) next available byte in the SA.
Best bet would be to compile a Metal C "hello world" that calls
sprintf and see what the setup and call looks like.

There also seems to be a choice of using the library routines from
LPA, or binding them with your program.

Tony H.

----------------------------------------------------------------------
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