使用 WTO 在 Metal C 中打印

发布于 2024-07-23 06:20:47 字数 1294 浏览 8 评论 0原文

我正在尝试使用 Metal C 中的 WTO 指令将“Hello World”打印到我的作业日志中。 这是基于 z/OS V1R10.0 Metal C 编程指南和参考第 1.2.3.5 节中的示例。当我使用 WTO 时,我的缓冲区包含 0 或 ASCII 到 EBCDIC 转换时出现问题。 我在下面粘贴了我的工作日志的相关部分,然后是我的代码,然后是 IBM 示例中我无法编译的代码。 作业日志

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

我的代码

#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 代码

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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

扶醉桌前 2024-07-30 06:20:47

IBM 示例对我有用(在 Z/os 1.9 下),但我必须添加
设置代码页的编译指示:
在示例之上:
#pragma filetag("IBM-500")
编译器不接受 char text[80] 中的 [ 和 ];
我也尝试将 char text[80] 更改为 char *text 但我得到了相同的结果
像你一样奇怪的结果。

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.

悲喜皆因你 2024-07-30 06:20:47

也许两个版本的结构在内存中的布局不相同? 我在 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;
}

以下是结果:

size 8 struct 0x22cce0 string 0x402000

但是,如果我将文本参数的类型更改为 char[80],结果将更改为:

size 84 struct 0x22cc80 string 0x22cc84

WTO 指令可能期望将字符串直接打包到该结构中。

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.

七婞 2024-07-30 06:20:47

为什么不能编译 IBM 示例? 它对我来说工作得很好 - 也许你可以向我们展示你的编译器参数和错误消息?

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

月亮邮递员 2024-07-30 06:20:47

您通过 TN3270 客户端编辑代码吗? 该问题很可能与模拟器中的代码页有关。 例如,我需要在 ISPF 中进行以下更改:c x'4A' x'AD' all(对于 [ )和 c x'5A' x'BD' (对于 ])以便编译源代码...

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文