Run your first program in Assembly Language using Visual Studio

Assembly Language Programming Tutorial

Run your first program in Assembly Language using Visual Studio

1. First of all, download and install
Visual Studio Community 2017

2. Open Visual Studio

3. Create New Project from
File > New > Project.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

4. Select option for your project as visual studio allow you to program in a lot of languages, to write a program in assembly follow the following steps:
Installed > Templates > Visual C++ > Win32 > Win32 Console Application

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

5. From Solution Explorer, right click source file and click add new item, and follow steps below:

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Save the source file with .asm extension

6. Now to make your assembler work, you have to set a few options, Right click your project name and open build dependencies.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Select masm and click ok.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

7. Now right click your program file name and open properties.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

8. In Item Type select Microsoft Macro Assembler from drop down.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

9. In Excluded from Build select No.

Copy the following code into your source file.

; AddTwo.asm - adds two 32-bit integers
; Chapter 3 example

.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD

.code
main PROC
mov  eax,5
; move 5 to the eax register
add  eax,6
; add 6 to the eax register

INVOKE ExitProcess,0
main ENDP
END main

10. Put a break point in your program and run your program.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

If any window is not visible to you you can view it by selecting from
Windows > Registers

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Right click register window to view status flags.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Now press F10 to see step by step execution of your program.

Assembly Basics, Coding for beginners, Coding tutorial, Computer Science, Learn programming, Programming Tutorial, Assembly Language, Visual Studio, Learn Coding, Programming for beginners

Congratulations! Your first program in assembly has run successfully.