在 win32 上使用 MASM 组装的程序没有控制台输出

发布于 2024-12-23 13:18:02 字数 1002 浏览 1 评论 0原文

我正在运行一些 MASM32 示例(来自 www.masm32.com),我注意到命令行框中的控制台输出为空白(程序编译、链接并运行,但没有输出。

    .486                                    ; create 32 bit code
    .model flat, stdcall                    ; 32 bit memory model
    option casemap :none                    ; case sensitive

    include \masm32\include\windows.inc     ; always first
    include \masm32\macros\macros.asm       ; MASM support macros
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

    .code                       ; Tell MASM where the code starts


start:                          ; The CODE entry point to the program

    print chr$("Hey, this actually works.",13,10)
    exit


end start                       ; Tell MASM where the program ends

I'm running some MASM32 examples (from www.masm32.com) and I notice that the console output is blank in my command line box (program compiles, links and runs but no output.

    .486                                    ; create 32 bit code
    .model flat, stdcall                    ; 32 bit memory model
    option casemap :none                    ; case sensitive

    include \masm32\include\windows.inc     ; always first
    include \masm32\macros\macros.asm       ; MASM support macros
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

    .code                       ; Tell MASM where the code starts


start:                          ; The CODE entry point to the program

    print chr$("Hey, this actually works.",13,10)
    exit


end start                       ; Tell MASM where the program ends

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

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

发布评论

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

评论(1

九歌凝 2024-12-30 13:18:02

当您链接 Win32 的 PE 程序时,您可以将所需的子系统标记为“GUI”或“Console”。如果您已将其链接为 GUI 模式程序,那么当您从命令提示符运行 EXE 时,Windows 不会将控制台附加到您正在输入的窗口。这听起来像你所描述的症状。

确保将可执行文件与“console”子系统标志链接。

When you link a PE program for Win32, you can mark the required subsystem as either "GUI" or "Console". If you have linked this as a GUI mode program, then when you run the EXE from a command prompt Windows will not attach the console to the window you are typing into. This sounds like the symptoms you have described.

Make sure that you link your executable with the "console" subsystem flag.

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