2013-10-02 66 views
1

我使用的是masm32編譯和鏈接在Windows 7,它適用於下面的代碼很好。然而,調用stdOut並不是簡單地在我的命令提示符上打印任何內容。我究竟做錯了什麼?調用標準輸出的masm32沒有輸出

.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

解決......我用錯了參數鏈接

如何給它正確鏈接

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

怎麼沒有這個程序鏈接

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