Search code examples
cmainframezosmetalc

using WTO to print from with in Metal C


I’m trying to use the WTO instruction from with in Metal C to print out "Hello World" to my job log. This is based on the example in section 1.2.3.5 of the z/OS V1R10.0 Metal C Programming Guide and Reference It appears when I use WTO I am having either issues with my buffer containing 0 or ASCII to EBCDIC conversion. I’ve pasted the relevant section of my job log below, followed by my code, then the code from the IBM example which I could not get to compile. Job log

09.01.56 J0686275  IEF403I IMIJWS0G - STARTED - TIME=09.01.56
 09.01.56 J0686275  +...0.......
 09.01.56 J0686275  -                                         --TIMINGS (MINS.)--            ----PAGING COUNTS---
09.01.56 J0686275  -IMIJWS0G          GO          00      6    .00    .00    .00   1292   0      0      0      0     0     1
 09.01.56 J0686275  IEF404I IMIJWS0G - ENDED - TIME=09.01.56

My code

#include 
#include 
#include 
 int main()
 {
                                    struct WTO_PARM {
               unsigned short len;
               unsigned short code;
               char* text;
            } wto_buff = { 4+11, 0, "hello world" };
            __asm( " WTO  MF=(E,(%0)) " : : "r"(&wto_buff));

        }

IBM code

int main() {

            struct WTO_PARM {
               unsigned short len;
               unsigned short code;
               char text[80];            } wto_buff = { 4+11, 0, "hello world" };            __asm( " WTO  MF=(E,(%0)) " : : "r"(&wto_buff));
            return 0;
        }

Solution

  • The IBM example worked for me (under Z/os 1.9) but I had to add a pragma to set the codepage: on top of the example: #pragma filetag("IBM-500") The compiler did not accept the [ and ] in the char text[80]; I've tried to change char text[80] into char *text as well but I got the same strange result as you.