Question

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;
        }
Was it helpful?

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.

OTHER TIPS

Perhaps the layout in memory of the two versions of the struct isn't the same? I tried this in gcc:

#include <stdio.h>

struct WTO_PARM {
    unsigned short len;
    unsigned short code;
    char *text;
};

int main()
{
    struct WTO_PARM moo = { 4+11,0,"hello" };
    printf("size %zu struct %p string %p\n", sizeof(struct WTO_PARM),&moo,moo.text);
    return 0;
}

Here are the results:

size 8 struct 0x22cce0 string 0x402000

However, if I change the type of the text parameter to char[80], the results change to:

size 84 struct 0x22cc80 string 0x22cc84

The WTO instruction likely expects the string to be packed right into that struct.

Why can't you compile the IBM sample? It works fine for me - perhaps you could show us your compiler parms and error messages?

Do you edit your code via TN3270 client ? It's very likely that the problem is related to the code page in your emulator. For example I need to make the following change in ISPF : c x'4A' x'AD' all (for [ ) and c x'5A' x'BD' (for ]) in order to compile the source ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top