Thread: MASM 7, wont compile.

  1. #1
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    Angry MASM 7, wont compile.

    I figured that it is time for learning some x86 Assembly tonight. However, when I installed MASM 7 and tried compiling an example of using MessageBoxA API the compiler brings up a console screen and says:

    Code:
     Assembling: F:\Assembly.asm
    MASM : fatal error A1000: cannot open file : F:\Assembly.asm
    _
    Assembly Error
    Press Any Key To Continue. . .
    So I tried saving, then reloading the asm example... but that didnt work either. So then I went to File>>Set Current Directory, and tried setting that Directory to the MASM folder, and the then the directory containing the asm file that I had saved. This is really annoying me, if anyone knows why the d*mn thing would do that please give me a hand.

  2. #2
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Seems a problem with the setting up of your editor.....

    Try this

    Code:
    .386
    .model flat,stdcall
    option casemap:none
    include \masm32\include\windows.inc
    include \masm32\include\user32.inc
    includelib \masm32\lib\user32.lib          
    include \masm32\include\kernel32.inc
    includelib \masm32\lib\kernel32.lib
    
    WinMain proto :DWORD,:DWORD,:DWORD,:DWORD
    
    ; -------------------------------
    ; literal string MACRO
    ; -------------------------------
          literal MACRO quoted_text:VARARG
            LOCAL local_text
            .data
              local_text db quoted_text,0
            .code
            EXITM <local_text>
          ENDM
    ; --------------------------------
    ; string address in INVOKE format
    ; --------------------------------
          SADD MACRO quoted_text:VARARG
            EXITM <ADDR literal(quoted_text)>
          ENDM
    
    ;#####################################################
    ;#####################################################
    
    .DATA   
    
    ;#####################################################
    ;#####################################################
    
    .DATA?      
    
    hInstance HINSTANCE ?       
    CommandLine LPSTR ?
    
    ;#####################################################
    ;#####################################################
    
    ; STARTUP
    
    .CODE              
    start:
    invoke GetModuleHandle, NULL  
    
    mov hInstance,eax
    invoke GetCommandLine                 
    
    mov CommandLine,eax
    invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT 
    invoke ExitProcess, eax   
    
    ;#####################################################
    ;#####################################################
    
    WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
       
       invoke MessageBoxA, NULL,SADD("From MASM"),SADD("Hello World"),MB_OK
       mov    eax,NULL                                          
       ret
    WinMain endp
    end start
    Save as Hello.asm......

    Now open a command prompt and direct it to the folder in which this file resides. Type this

    C:\masm32\BIN\ML.EXE /c /coff /Cp Hello.asm
    Assuming ML is indeed in C:\masm32\BIN (this is the default install folder anyway)

    Now this should exit and in the folder, you will find a new file called Hello.obj. Now type

    C:\masm32\BIN\LINK.EXE /SUBSYSTEM:WINDOWS /LIBPATH:c:\masm32\lib Hello
    Again I'm assuming the lib folder and bin folder are in those places...if not, change the paths

    This should now produce Hello.exe....run it and see

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,793
    Oh and make sure the "include" statements at the top of the code point to the right directories also

  4. #4
    Registered User Xei's Avatar
    Join Date
    May 2002
    Posts
    719

    Thanks

    Yes, that worked. Thank you for your help.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Include Compile Info
    By rkensparc in forum C Programming
    Replies: 1
    Last Post: 08-02-2007, 09:38 AM
  2. C and C++ compile speed
    By swgh in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 01-02-2007, 02:37 PM
  3. Compile as you type
    By Rocketmagnet in forum A Brief History of Cprogramming.com
    Replies: 33
    Last Post: 12-07-2006, 01:36 PM
  4. How to compile mfc libs from platform sdk
    By tjcbs in forum Windows Programming
    Replies: 6
    Last Post: 11-19-2006, 08:20 AM
  5. Compile crashes certain windows
    By Loduwijk in forum C++ Programming
    Replies: 5
    Last Post: 03-26-2006, 09:05 PM