Although there are similarities in each of the following three sections, there are also differences and the
directions are written separately to avoid confusion. The first is for C programs with inline assembly, the
second for 32-bit integer and floating-point MASM programs, and the third is for 64-bit integer MASM
programs. Also, the fourth section contains directions for obtaining an assembly listing for MASM
programs (
.lst file). Copyright, J.T. Streib, 2019.

C Programs with Inline Assembly

  • To create a new project, on the Visual Studio 2019 Get Started page, click Create new project.
  • On the next Create a new Project page, choose Empty Project (where it also says C++, Windows,
    and Console underneath this selection), and click Next.
  • On the Configure your new project page, in the Project Name box use the default Project1 name or
    key in another name such as TestInLine. Then determine Location where the project should be
    stored, whether in the default folder given or key in another location such as F:\ for a jump drive.
    By default, the Solution name is the same as the Project name, then click the Create button.
  • In the Solution Explorer, right click on the name of the application (default Project1), select
    Properties, then under Linker, select System, and verify that the SubSystem is Console. (If not
    select it from the list).
  • Again, in the Solution Explorer, expand Project1 (if not done so already), and right click on Source
    Files, hover on Add, and click New Item. Note that the default is C++ File (.cpp). At the bottom of
    the screen use the default name Source or use a different name and change the extension from
         .cpp to .c (as in source.c). In either case be sure to use a .c extension (because this indicates to
        
 use the C compiler instead of the C++ compiler) and then click Add.
  • One can now key in a program or copy and paste a complete program from the “Guide to Assembly
    Language” website. Then click on BUILD and Build Solution. If there are no syntax errors, then click
    on DEBUG and then Start Without Debugging.

32-bit Integer and Floating-Point MASM Programs

  • To create a new project, on the Visual Studio 2019 Get Started page, click Create new project.
  • On the next Create a new project page, choose Empty Project (where it also says C++, Windows,
    and Console underneath this selection), and click Next.
  • On the Configure your new project page, in the Project Name box use the default Project1 name or
    key in another name such as Test32Bit or TestFloatingPoint. Then determine Location where the
    project should be stored, whether in the default folder given or key in another location such as F:/
    for a jump drive. By default, the Solution name is the same as the Project name, then click the
    Create button.
  • Make sure in the ribbon that x86 appears in the Solution Platforms box which is next to the Solution
    Configurations box that has the word Debug in it. If not, select it from the list. By hovering over the
    boxes, one can see the names of the boxes.
  • Now in the Solution Explorer (which can appear on either the left or right side), right click the name
    of the application which appear in bold near the top (default Project1), then hover on Build
    Dependencies and then click Build Customizations. Then check the masm box and click OK.
  • Again, in the Solution Explorer, right click on the name of the project (default Project1) and select
    Properties. Then expand Linker and then click on Input. In the Additional Dependencies, type or
    paste msvcrt.lib;legacy_stdio_definitions.lib; at the beginning of the list. Be careful not to delete any
    other entries, do not forget the semi-colons, and then click OK. Alternatively, or if there are
    problems when building a solution, the above can be added at the beginning of the program as
    follows:
                     includelib msvcrt.lib
                     includelib legacy_stdio_definitions.lib

  • Then again in the Solution Explorer, right click on the name of the application (default Project1),
    select Properties, then under Linker, select System, and verify that the SubSystem is Console. (If
    not select it from the list). Also, under Linker, select Advanced and verify the Entry Point is blank
    (and does not say main).
  • Now in the Solution Explorer, expand Project1 (if not done so already), and right click on Source
    Files, hover on Add, and click New Item. Note that the default is C++ File (.cpp). At the bottom of
    the screen use the default name source or use a different name and change the extension from
         .cpp to .asm (as in source.asm). In either case be sure to use a .asm extension (because this
       
  indicates to use the Microsoft Assembler, MASM, instead of the C++ compiler) and then click Add.
  • One can now key in a program or copy and paste a complete program from the “Guide to Assembly
    Language” website. Then click on BUILD and Build Solution. If there are no syntax errors, then click
    on DEBUG and then Start Without Debugging. (For information on using the Debugger, see
    problem 10 in Section 12.12 of the text.)

64-bit Integer MASM Programs

  • To create a new project, on the Visual Studio 2019 Get Started page, click Create new project.
  • On the next Create a new project page, choose Empty Project (where it also says C++, Windows,
    and Console underneath this selection), and click Next.
  • On the Configure your new project page, in the Project Name box use the default Project1 name or
    key in another name such as Test64Bit. Then determine Location where the project should be
    stored, whether in the default folder given or key in another location such as F:\ for a jump drive.
    By default, the Solution name is the same as the Project name, then click the Create button.
  • Select x64 in the ribbon in the Solution Platforms box which is next to the Solution Configurations
    box that has the word Debug in it. By hovering over the boxes, one can see the names of the boxes.
  • Now in the Solution Explorer (which can appear on either the left or right side), right click the name
    of the application which appear in bold near the top (default Project1), then hover on Build
    Dependencies and then click Build Customizations. Then check the masm box and click OK.
  • Again, in the Solution Explorer, right click on the name of the project (default Project1) and select
         Properties. Then expand Linker and then click on Input. In the Additional Dependencies, type or
         paste libcmt.lib;legacy_stdio_definitions.lib; at the beginning of the list. Be careful not to delete any
         
other entries, do not forget the semi-colons, and then click OK. Alternatively, or if there are
        
 problems when building a solution, the above can be added at the beginning of the program as
        
 follows:
                     includelib libcmt.lib
                     includelib legacy_stdio_definitions.lib

  • Again, in the Solution Explorer, right click on the name of the project (default Project1) and select
    Properties. Then expand Linker and then click on System. In the Enable Large Addresses, select
    No (/LARGEADDRESSAWARE:NO). While in the System area, verify that the SubSystem is
    Console. (if not select it from the list). Then click Apply and then click OK.
  • Then again in the Solution Explorer, right click on the name of the application (default Project1),
    select Properties, then under Linker, select Advanced and verify the Entry Point is blank (and does
    not say main).
  • Now in the Solution Explorer, expand Project1 (if not done so already), and right click on Source
    Files, hover on Add, and click New Item. Note that the default is C++ File (.cpp). At the bottom of
    the screen use the default name source or use a different name and change the extension from
         .cpp to .asm (as in source.asm). In either case be sure to use a .asm extension (because this
        
 indicates to use the Microsoft Assembler, MASM, instead of the C++ compiler) and then click Add.
  • One can now key in a program or copy and paste a complete program from the  “Guide to
    Assembly Language” website. Then click on BUILD and Build Solution. If there are no syntax
    errors, then click on DEBUG and then Start Without Debugging. (For information on using the
    Debugger, see problem 10 in Section 12.12 in the text.)

MASM Assembly Listings (.lst file)

These directions are for obtaining an assembly listing (.lst file) for 32-bit integer, floating-point,
and 64-bit integer MASM programs as created in the two preceding section
s above.

  • Right click on the name of the project in the Solution Explorer, click on Properties, and expand
          Microsoft Macro Assembler. Make sure that if assembling a 32-bit program, such as the one in
         
 Sect. 12.9 of the text, that the Platform: in the top part of the window says Win32 and if assembling
         
 a 64-bit program, such as the one in Sect. 12.10, that the Platform: in the top part of the window
         
 says x64.Then click on Listing File and select Yes(/Sa) for List All Available Information, and type in
        
  $(ProjectName).lst for Assembled Code Listing File. Then click Apply and then OK.
  • After building the program as discussed in the last bullet point in the two preceding sections
          above,  the .lst file can be found by clicking File, then Open, then File…, and then clicking on
        
  the .lst file to open it.
  • Be careful not to make changes to the .lst file, but only to the .asm file because the changes
          made to the .lst file will be ignored by the assembler.
Notes on Visual Studio 2019