masm32 invoking stdout gives no output

为君一笑 提交于 2019-12-02 10:39:58

问题


I am using masm32 to compile and link on windows 7, which works just fine with below code. However invoking stdOut isn't simply printing anything on my command prompt. what am i doing wrong?

.386

.model flat, stdcall
    option casemap:none

    include C:\masm32\include\windows.inc
    include C:\masm32\include\kernel32.inc
    include C:\masm32\include\user32.inc
    include C:\masm32\include\masm32.inc

    includelib C:\masm32\lib\kernel32.lib
    includelib C:\masm32\lib\user32.lib
    includelib C:\masm32\lib\masm32.lib

.data    
    MsgBoxCaption   db "Message Box Caption", 0
    MsgBoxText      db "Win32 Assembly is great!", 0

.data? 
    ; declare an uninitialized byte, referred to as location sum
    sum             dd ?

.code
    start:    
        mov eax, 1d
        mov ebx, 1d

        ; result will be stored in the first argument
        add eax, ebx  

        ; push eax onto the stack
        push eax

        ; pop value into sum
        pop sum

        ; invoke MessageBox, NULL, addr MsgBoxText, addr MsgBoxCaption, MB_OK

        invoke StdOut, addr MsgBoxCaption
        invoke StdOut, addr sum

        ; exit with status code 0 
        invoke ExitProcess, 0
    end start

回答1:


Solved... i was using the wrong parameter for the linker

How to link it correctly

ml /c /coff /Cp hello.asm
link /subsystem:console /libpath:c:\masm32\lib hello.obj

How NOT to link this program

ml /c /coff /Cp hello.asm
link /subsystem:windows /libpath:c:\masm32\lib hello.obj


来源:https://stackoverflow.com/questions/19144764/masm32-invoking-stdout-gives-no-output

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!