Using MASM (Microsoft Macro Assembler)


This page discusses how to use MASM:
  1. Download and Install Microsoft Visual Studio Community.
  2. Visual Studio Community is a fully-featured, extensible, free IDE for creating modern applications for Android, iOS, Windows, as well as web applications and cloud services.

  3. Enable MASM in a C++ Project.



  4. Download and install ASP.NET Downloads, which consists of three packages:


    • ASP.NET,
    • Web Tools 2012,
    • Windows Azure SDK, and
    • Web frameworks.


  5. Start the Visual Web Developer (VWD) 2010 Express Edition by selecting the Windows options:
       Start  All Programs 
              Microsoft Visual Studio 2010 Express
              Microsoft Visual Web Developer 2010 Express Edition

  6. Click the hyperlink “New Web Site...” in the section “Recent Projects:
    • Pick the template: “ASP.NET Web Site” and “Visual Basic” and
    • Create a directory, such as “Web location: ⇒ File System ⇒ C:\course\260\ASP.NET\WebSite1,” to store your Web site.



    Lookahead.asm
     ; hello64.asm - Simple 64-bit Hello World for Windows
    ; Assemble: ml64 hello64.asm /link /subsystem:console /entry:main
    
    includelib ucrt.lib
    includelib legacy_stdio_definitions.lib
    includelib msvcrt.lib
    
    .data
        msg db "Hello from 64-bit MASM!", 10, 0
    
    .code
    externdef printf:proc
    externdef exit:proc
    
    main proc
        sub rsp, 40          ; Shadow space (32 bytes) + alignment
        lea rcx, msg         ; First argument: address of the string
        call printf          ; Call the C library printf function
        add rsp, 40          ; Restore stack pointer
        
        xor ecx, ecx         ; Exit code 0
        call exit
    main endp
    end

    For how to write .aspx files, check the ASP.NET Quickstart Tutorial.

  7. Build the Web site by selecting the VWD options:
      Debug  Build Web Site

  8. Check the Web site on a browser by selecting the VWD options:
      Debug  Start Debugging


    Unless there are a Web server and an IP address on your machine, the Web pages can only be accessed by a browser on the local machine. You can see this by noticing the URL is
      https://localhost:60283/WebSite1/Default.aspx
    For grading, you have to submit a CD containing the Website and allow the instructor to execute it on his machine.

  9. Execute the Web site and check the result: