Warriors of the Visual Studio, assemble! (Visual Studio Warriors, assemble it!) ) Original July 12, 2009 19:40:00 Tags: compilation/mic

Source: Internet
Author: User
warriors of the Visual Studio, assemble! (The Warriors of Visual studio, assemble it.) )Original July 12, 2009 19:40:00 Tags: compilation/Microsoft/express/file/assembly/command
Warriors of the Visual Studio, assemble!
If you ' ve recently purchased Assembly Language for intel-based Computers, 5th edition, you probably want to get the SOFTW is set up so you can start working. This tutorial should make the process easier. If you're a hurry to get started, you have need to read Item 1. Required setup for 32-bit applications Building 16-bit Applications (chapters 12-16) Project properties Settings Creating A project from scratch generating a source listing file Using the Visual Studio debugger MASM syntax highlighting Assembli Ng, linking, and debugging with a batch file

Found An error in this document? Please email me immediately. Except where noted, all instructions in this document apply equally to Visual Studio and Visual C + + Express. Required Setup for 32-bit applications First, you must install some version of Visual Studio or Visual C + + Express:if you have installed Visual Studio Prof  Essional or Team Suite, these products also contain the Microsoft assembler 9.0. If you have installed Visual C + + Express Service Pack 1, it includes MASM 9.0. If you have installed Visual C + + 2005 Express, you must also download the Microsoft Assembler 8.0
(see below). Downloading Microsoft Express Editions Visual C + + Express Visual C + + 2005 Express.

You can verify that the Microsoft assembler are installed by looking for the file Ml.exe in The/vc/bin folder of your Visu Al Studio installation directory, such as C:/Program Files/microsoft Visual Studio 9.0/vc/bin.

Downloading and installing the Microsoft Assembler 8.0:visit Microsoft ' s MASM 8.0 download site. Follow the download and installation instructions on the Microsoft page. If the link is broken, please let us know by email. Note that this MASM download only works with Visual C + + 2005 Express. MASM 8.0 is almost identical to MASM 9.0. Next:install The book ' s Example Programs

Click this link to get the latest copy of the book ' s link libraries and example programs. The examples is stored in a self-extracting archive file, automatically extracts to Thec:/irvine folder. Unless you has some objection to using the, does not alter the path. (Lab managers:you can designate C:/irvine directory as read-only.) If you plan to change the installation location, read our instructions relating to changing project properties.

The folllowing files would be copied into the C:/irvine directory:

Filename

Description

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)

Link16.exe 16-BIT linker

Irvine32.lib

32-bit link function library used with this book

Macros.inc

Include file containing macros (explained in Chapter 10)

Smallwin.inc

Small-sized include file, used by Irvine32.inc

Make16.bat Batch file for building 16-bit applications

Virtualkeys.inc

Keyboard code definitions file, used by Irvine32.inc

A subdirectory named Examples would contain all the example programs shown in the book. Building a Sample Assembly Language Program Preliminary Step:set Tab Size to 5

Start Visual C + + Express, and select Options from the Tools menu. Select Text Editor, select All Languages, and select Tabs:

Set the Tab size and Indent size to 5. Opening a Project

Visual Studio and Visual C + + Express require assembly language source files to belong to Aproject, which was 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. We have created a sample project folder in The c:/irvine/examples directory, and its name is project_sample .

Do the following steps, in Order:start visual Studio or Visual C + + Express. If you ' re using Visual Studio, Select open project from the File menu. Or, if you ' re using Visual C + + Express, Select open, and Select project/solution. Navigate to The c:/irvine/examples/project_sample folder and open the file NamedProject.sln. In The solution Explorer window, click the + symbol next to the item named project to expand it. Double-click the file Named main.asm to open it in the editing window. (Visual Studio users may see a popup dialog asking for the encoding method used in the ASM file. Just click the OK button To continue.)

Tip:if The Solution Explorer window is not visible, select Solution Explorer from TheView menu. Also, if you don't see main.asm in the Solution Explorer window, look at the tabs along the bottom of the window. Click The Solution Explorer tab.

You should see the "following program" in the editor window:

TITLE MASM Template				(main.asm)

; Description:
; 
; Revision Date:

INCLUDE irvine32.inc

. Data
mymessage BYTE "MASM Program Example", 0dh,0ah,0

. Code
Main PROC call
    clrscr

    mov  edx,offset mymessage call
    writestring

    exit
main ENDP

END Main

Later, we'll show you how to copy the This program and use it as a starting point to write your own programs. Build The program

Next, you'll build (assemble and link) The sample program:if you ' re using Visual C + + Express, select Build Solution Fro M the Build menu. If you ' re using Visual Studio, select Build Project from the Build menu.

In the Output window at the bottom of the screens, you should see messages similar to the following, indicating the build p Rogress:

1>------Build started:Project:Project, configuration:debug Win32------
1>assembling ...
1>assembling:./main.asm
1>linking
... 1>embedding manifest
... 1>build log was saved at "file://g:/masm/Project_sample/Debug/BuildLog.htm"
1>project-0 error (s), 0 warning ( s)
========== Build:1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

If you don't see these messages, the project had probably not been modified since it is last built. No problem--just Add a space somewhere in the document, save it, and try the Build command again. Run The program

Select Start without Debugging from the Debug menu. The following console window should appear, although your window would be larger than the one shown here:

The "Press any key to continue ..." message is automatically generated by Visual C + + Express.

Congratulations, you are just run your first Assembly Language program.

Press any key to close the Console window.

When you assembled and linked the project, a file named Project.exe is created inside the project ' S/debug folder. This is the file of the executes when you run the project. You can execute Project.exe by double-clicking its name inside Windows Explorer, but it'll just flash on the screen and Disappear. That's because Windows Explorer does not pause the display before closing the command window.

Creating New Projects of Your Own

Before long, you'll want to create your own projects. The easiest-to-do-is-to-copy the Entire c:/irvine/examples/project_sample folder to a new location. Copy it to a folder in which you have Read/write permissions. (If you ' re working in a college computer lab, a useful location is a portable USB drive. Then you can modify the program, build, and run it again. Step 5:running The Sample program in Debug Mode

In this step, you'll set a breakpoint inside the sample program. Then you'll use the Visual C + + debugger to step through the program's execution one statement at a time. To begin stepping through your program in Debug mode, press the F10 key. A Yellow arrow would appear next to the first program statement (call CLRSCR). The arrow indicates that the statement was next to being executed. Press the F10 key (called Step over) to execute the current statement. Continue pressing F10 until the program was about to execute the exit statement. A Small Black window icon should appear on your Windows status bar. Open it and look at the contents of the Command window. You should see the words ' MASM program example ' in the window. Press F10 one more time to end of the program.

Registers

If you want to display the CPU registers, does the Following:start debugging the program and then select Windows from the Debu G menu. Select registers from the Drop-down list. The bottom window would display the register contents. Right click this window and check the item Flagsto enable the display of conditional flags.

You can interrupt a debugging session at any time by selecting Stop Debugging from the Debug menu. You can do the same by clicking the Blue Square button on the toolbar. To remove a breakpoint from the program, click the ' Red dot so ' it disappears. Setting a breakpoint

If 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 this point, the debugger drops into single-step mode. Click the mouse along the border to the left of the "call WriteString statement. A large red dot should appear in the margin. Select Start Debugging from the Debug menu. The program should run, and pause on the line with the breakpoint, showing the same Yellow arrow as before. Press F10 until the program finishes.

You can remove a breakpoint by clicking it red dot with the mouse. Take a few minutes to experiment with the Debug menu commands. Set more breakpoints and run of the program again. For the time being, you can use the F11 key to step through the "program" in the same and the F10 key did. Building and Running other Programs

Suppose want to run another example program, or possibly create your own program. Can either edit and modify Main.asm, or can remove main.asm from the project and insert some other. asm file into The project. To remove a program from a project without deleting the file, right-click its name in The solution Explorer window. In the context menu, select exclude from Project. If you change your mind and decide-to-add it back to the project, right-click in the same window, Select add, se Lect existing Item, and Select the file you want to add. To remove a program from a project and delete the source code file, select the file with the mouse and press the del& Nbsp;key. Or, you can right-click the file name and Selectremove. Adding a File to a Project

The easiest-to-add an assembly language source file to an open project was to drag their filename with the mouse from A Windows Explorer window onto the name of your project in the Solution Explorer window. A reference to the file (not a copy) would be inserted in your project ' s directory. Try this now:remove the Main.asm file from your project. ADD a reference to the file c:/irvine/examples/ch03/addsub.asm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.