Using Visual Studio I need you to write two assembly codes (they are below). I need a screen shot of the input and output for both codes ---- (It needs to be Visual Studios!) Please write the...

Using Visual Studio I need you to write two assembly codes (they are below). I need a screen shot of the input and output for both codes ---- (It needs to be Visual Studios!)

Please write the following small two programs and make sure to include screen shots of your source code output. I attached a file that shows the format for the assignment.


First Program:


Enter Your name first name :


Enter Your name last name :


Output: displays your first and Last name.


Second program:


Enter Three numbers:


Output:


Result addition of the entered three number


Multiplication result of the entered numbers



Getting Started with MASM and Visual Studio 2017



Required Setup for 32-bit Applications


After you have downloaded and installed the VS 2017 Community Edition, you may need to install the Visual C++ language option. First, let's see if it has already been installed (as often happens in college computer labs). Select New Project from the File menu and view the Installed >> Templates entries on the left side of the New Project. Expand the Other Languages section:



Note: If you do not see Visual C++ in the list, click the Open Visual Studio installer hyperlink. It runs a separate program. If your computer is in a college laboratory, your account may not have sufficient privileges to run this program, so you can ask your lab supervisor to do it.


If you were able to run the VS installer, close the main Visual Studio window (not the installer), and in the installer window, click theDesktop development with C++ button in the installer window, look at the Summary list on the right side to verify that VC++ is selected, and click the Modify button in the lower right corner of the window.


You will have to wait a while for the installation to finish. Meanwhile, why don't you read Chapter 1 of my book?


The Visual C++ language includes the Microsoft Assembler (MASM). To verify that MASM was installed, open a Windows Explorer window and look for the file namedml.exe in the Visual Studio installation directory, such asC:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\bin\HostX64\x86.



The Book's Example Programs


At the top of this document, we explained how to download the file named Irvine.zip and extract it into the C:\Irvine folder. Unless you have some objection to using that location, do not alter the path. (Note to lab administrators: you can designate c:\Irvine directory as read-only.).


The folllowing files should appear in the c:\Irvine directory:



































































Filename




Description



b16.asm, b32.asm



Blank templates for 16-bit and 32-bit assembly language source files



GraphWin.inc



Include file for writing Windows applications



Irvine16.inc



Include file used with the Irvine16 link library (16-bit applications)



Irvine16.lib



16-bit link function library used with this book



Irvine32.inc



Include file used with the Irvine32 link library (32-bit applications)



Irvine32.lib



Irvine's 32-bit link library



Kernel32.lib



32-bit link library for Windows API



Link16.exe



16-bit Microsoft linker



Macros.inc



Irvine's macro include file (see Chapter 10)



make16_vs2012.bat



Visual Studio 2012 batch file for building 16-bit applications



make16_vs2013.bat



Visual Studio 2013 batch file for building 16-bit applications



SmallWin.inc



Small-sized include file containing MS-Windows definitions, used by Irvine32.inc



User32.lib



MS-Windows basic I/O link library



VirtualKeys.inc



Keyboard code definitions file, used by Irvine32.inc



A subdirectory named Examples will contain all the example programs shown in the book, source code for the book's 16-, 32-, and 64-bit libraries, and two sample projects for earlier versions of Visual Studio.



Setting up Visual Studio



Select the C++ Configuration


Visual Studio supports multiple programming languages and application types. The C++ programming language configuration most closely matches that of assembly language programming, so we suggest the following steps:


Select Tools | Import and Export Settings from the menu


Select the "Import selected environment settings" radio button


Select the "No, just import..." radio button


Select "Visual C++" from the Default Settings List and click the Next button


Click the Finish button, then click the Close button


Notice the tabs on the left and right sides of the Visual Studio workspace. Close the Server Explorer, Toolbox, and Properties tabs. Use the mouse to drag the Solution Explorer tool window to the right side of the workspace. You can also select other tabs at the bottom of this window, such as "Class View", "Property Manager", and "Team Explorer", and close them. They will not be used in the future. If you need to bring back the Solution Explorer window at any time in the future, select View from the menu, and locate Solution Explorer in the list of views.



Optional Step: Set the tab indent size


Start Visual Studio and selectOptions from theTools menu. SelectText Editor, SelectAll Languages, and selectTabs. Optionally, you may want to select theInsert spaces radio button:


Set the Tab Size and Indent Size to 5.



Optional Step: Add the Start Without Debugging command


As you learn to generate output directly to the console window in your programs, you may want to be able to run programs without debugging them. To do that, you need to add a new command to Visual Studio's Debug menu. Here's how to do it:


Select Customize from the Tools menu


Select the Commands tab at the top of the Customize window


From the dropdown list next to the Menu Bar radio button, select Debug


Click the Add Command... button


In the Add Command dialog window, select Debug from the Categories list


SelectStart Without Debugging in the Commands list


Click the OK button to close the Add Command dialog window


Optionally, you can click the Move Down button to reposition the new command in the Debug menu's list


Click the Close button to close the Customize dialog window


Click the Debug menu and verify that the new command appears


In fact, you can use a similar sequence to customize any of the menus and toolbars in Visual Studio.



Tutorial: Building and running a 32-bit program


Now you're ready to open and build your first 32-bit project.



Opening a Project


Visual Studio requires assembly language source files to belong to aproject, which is a kind of container. A project holds configuration information such as the locations of the assembler, linker, and required libraries. A project has its own folder, and it holds the names and locations of all files belonging to it.


If you have not already done so,Right-click here to download a zip file containing an up-to-date Visual Studio 2017 project that has been configured for assembly language. After downloading this file, un-zip it into your working directory. It contains a sample asm test file named AddTwo.asm.


Follow these steps:


Start Visual Studio.


Open our sample Visual Studio project file by selectingFile/Open/Project from the Visual Studio menu.


Navigate to your working folder where you unzipped our project file, and select the file namedProject.sln.


Once the project has been opened, you will see the project name in Visual Studio'sSolution Explorerwindow. You should also see an assembly language source file in the project named AddTwo.asm. Double-click the file name to open it in the editor.


You should see the following program in the editor window:










; 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



        add     eax,6






        invoke ExitProcess,0



main endp



end main



In the future, you can use this file as a starting point to create new programs by copying it and renaming the copy in the Solution Explorer window.



Adding a File to a Project: If you need to add an .asm file to an open project, do the following: (1) Right-click the project name in the Visual Studio window, select Add, select Existing Item. (2) In theAdd Existing Itemdialog window, browse to the location of the file you want to add, select the filename, and click the Add button to close the dialog window.



Build the Program


Now you will build (assemble and link) the sample program. SelectBuild Project from the Build menu. In the Output window for Visual Studio at the bottom of the screen, you should see messages similar to the following, indicating the build progress:



1>------ Build started: Project: Project, Configuration: Debug Win32 ------



1>Assembling ..\Project32_VS2017\AddTwo.asm...



1>Project.vcxproj -> ...\Project32_VS2017\Debug\Project.exe



1>Project.vcxproj -> ...\Project32_VS2017\Debug\Project.pdb (Full PDB)



========== Rebuild All: 1 succeeded, 0 failed, 0 skipped ==========


If you do not see these messages, the project has probably not been modified since it was last built. No problem--just selectRebuild Project from the Build menu.



Run the Program in Debug Mode


The easiest way to run your first program is to use the debugger. First, you must set a breakpoint. When you set a breakpoint in a program, you can use the debugger to execute the program a full speed (more or less) until it reaches the breakpoint. At that point, the debugger drops into single-step mode. Here's how to do it:


Make sure the ASM source code file is open in the editor window.


Click the mouse along the border to the left of themov eax,5 statement. A large red dot should appear in the margin.


SelectStart Debugging from the Debug menu. The program should run and pause on the line with the breakpoint.


Press the F10 key (calledStep Over) to execute the current statement. Continue pressing F10 until the program is about to execute theinvoke statement.


A small black window icon should appear on your Windows status bar. Open it and look at the contents of the Command window. The window should be blank because this program does not display any output.


Press F10 one more time to end the program.


You can remove a breakpoint by clicking its dot with the mouse. Take a few minutes to experiment with the Debug menu commands. Set more breakpoints and run the program again.


Here's what your program will look like when paused at the breakpoint:



Running a program from the Command Prompt: When you assembled and linked the project, a file named Project.exe was created inside the project's \Debug folder. This file executes when you run the project. You can execute any EXE by double-clicking its name inside Windows Explorer, but it will often just flash on the screen and disappear. That is because Windows Explorer does not pause the display before closing the command window. On the other hand, you can open a Command prompt window, move to the Debug directory, and run Project.exe by typing "Project" (without the quotes). You will need to do some reading on Windows shell commands if you plan to use the command line.


To remove a source file from the Visual Studio window, right-click its filename and selectRemove. The file will not be deleted from the file system. On the other hand, if you want to delete the file, select it and press the Del key.



Registers


Soon you will want to display CPU registers when debugging your programs. Here's how to make them visible: Set a breakpoint, run your program in Debug mode, selectWindows from theDebug menu, and then selectRegistersfrom the drop-down list. The Registers window may appear at the bottom of the workspace, as a tab highlighted in yellow. Use the mouse to drag the window to the right side of the work area. Right click inside the Registers window and check the itemFlags to enable the display of CPU status flags.


You can interrupt a debugging session at any time by selectingStop Debugging from the Debug menu. You can do the same by clicking the maroon-colored square button on the toolbar. To remove a breakpoint from a program, click its red dot to make it disappear.



Building and Running Other Programs


Suppose you want to run another example program, or possibly create your own program. You can remove the existing assembly language file from the Solution Explorer window and insert a new .asm file into the project.



  • To remove a program from a project without deleting the file, right-click its name in theSolution Explorer window. In the context menu, selectRemove. If you change your mind and decide to add it back to the project, right-click in the same window, selectAdd, selectExisting item, and select the file you want to add.



Adding a File to a Project


An easy way to add an assembly language source file to an open project is to drag its filename with the mouse from a Windows Explorer window onto the name of your project in the Solution Explorer window. The physical file will not be copied--the project only holds a reference to the file's location. Try this now:


Remove the AddTwo.asm file from your project.


Add a reference to the file Examples\ch03\AddTwoSum.asm to the project.


Build and run the project.



Copying a Source File


One way to make a copy of an existing source code file is to use Windows Explorer to copy the file into your project directory. Then, right-click the project name in Solution Explorer, select Add, select Existing Item, and select the filename.







May 18, 2022
SOLUTION.PDF

Get Answer To This Question

Submit New Assignment

Copy and Paste Your Assignment Here