使用 WTO 在 Metal C 中打印
我正在尝试使用 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
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.
也许两个版本的结构在内存中的布局不相同? 我在 gcc 中尝试过:
以下是结果:
但是,如果我将文本参数的类型更改为 char[80],结果将更改为:
WTO 指令可能期望将字符串直接打包到该结构中。
Perhaps the layout in memory of the two versions of the struct isn't the same? I tried this in gcc:
Here are the results:
However, if I change the type of the text parameter to char[80], the results change to:
The WTO instruction likely expects the string to be packed right into that struct.
为什么不能编译 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?
您通过 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 ...