You can call a Metal C program with just a simple stack.
 
If you want to use the library (like sprintf), you need to do the __cinit and 
__cterm calls.  There is a C structure file that you need to fill out to call 
__cinit and I believe the only parameter is the address of that structure.  I 
did not find a DSECT describing the structure only the H file.
 
So what I did was write a small C program that builds the structure on its 
stack, and then calls __cinit to build the C stack/heap/etc.  That C program 
also loads R12 with the address of the heap as described in the Metal C program 
and any other C programs that are to be used are compiled with the reserve R12 
option.
 
My logic is for doing all of the C work at one time and NOT for making sprintf 
available to an assembler program.  But you should still be able to have 
similar logic and just write 2 C programs:  one to do the __cinit and one to do 
the __cterm.  You would have to maintain the original C stack that you use to 
call the first program until after the __cterm is finished.
 
For initializing the structure, I just copied the example in the Metal C 
programming guide and modified to suit my needs.
 
Lloyd


>________________________________
> From: Donald Russell <[email protected]>
>To: [email protected] 
>Sent: Friday, March 14, 2014 1:51 AM
>Subject: Re: building text messages with substitutions
>  
>
>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....
>
>Sounds simple enough but I can't find what the parameter list looks like
>for those calls... Do I actually LOAD/DELETE those module names? I thought
>module names had to start with letter or national only.
>
>I don't want to write the whole thing in C, and use the occasional
>assembler macro, I have an assembler program and want to use sprintf to
>create a string of text with various substitutions in it.
>
>Once I have it all done I'm happy to share what I did...
>
>Cheers
>
>
>
>On Thursday, March 13, 2014, Tony Harminc <[email protected]> wrote:
>
>> On 13 March 2014 14:53, Donald Russell <[email protected]<javascript:;>>
>> wrote:
>> > Holly Smokes! Metal C looks perfect.... THANKS! :-) I just need sprintf
>> features....
>>
>> Please keep us posted with your results. I haven't actually tried it,
>> but I've thought about it a few times - enough to look at the calling
>> and environment conventions. They look pretty easy to meet, but stack
>> space requirements are large in comparison to typical assembler
>> programs. If you're calling only sprintf you could presumably reuse or
>> otherwise share the "stack", i.e. what you pass to the function
>> wouldn't have to be an actual stack that your program linkage
>> conventions use.
>>
>> Tony H.
>>
>> ----------------------------------------------------------------------
>> For IBM-MAIN subscribe / signoff / archive access instructions,
>> send email to [email protected] <javascript:;> with the message:
>> INFO IBM-MAIN
>>
>
>
>-- 
>Sent from iPhone Gmail Mobile
>
>
>----------------------------------------------------------------------
>For IBM-MAIN subscribe / signoff / archive access instructions,
>send email to [email protected] with the message: INFO IBM-MAIN
>
>
>

----------------------------------------------------------------------
For IBM-MAIN subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO IBM-MAIN

Reply via email to