Using WTO to print using in Metal C

I am trying to use the WTO instruction with help in Metal C to print "Hello World" in my work log. This is based on the example in section 1.2.3.5 of the Z / OS V1R10.0 Metal C Programming Guide and Help. Appears when I use the WTO. I am having problems with my buffer containing 0 or ASCII for EBCDIC conversion. Ive inserted the appropriate section of my work log below, then my code, and then the code from the IBM example, which I could not compile. Work log

  01/09/56 J0686275 IEF403I IMIJWS0G - STARTED - TIME = 09/09/56
  01/09/56 J0686275 + ... 0 .......
  01/09/56 J0686275 - --TIMINGS (MINS.) - ---- PAGING COUNTS ---
 01.09.56 J0686275 -IMIJWS0G GO 00 6 .00 .00 .00 1292 0 0 0 0 0 1
  01/09/56 J0686275 IEF404I IMIJWS0G - ENDED - TIME = 09/09/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;
         }
+4
source share
4 answers

The IBM example worked for me (under Z / os 1.9), but I had to add a pragma to set the code page: at the top of the example: #pragma filetag ("IBM-500") The compiler did not accept the text [and] in the text char [80 ]; I tried changing char [80] text to char * text, but I got the same weird result as you.

+2
source

Perhaps the layout in the memory of the two versions of the structure is not 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 expects the string to be packed directly into this structure.

+1
source

Why can't you compile an IBM sample? This works fine for me - maybe you could show us your compilers and error messages?

0
source

Are you editing your code through the TN3270 client? It is very likely that the problem is with the code page of 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]) to compile the source ...

0
source

Source: https://habr.com/ru/post/1285668/


All Articles