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.
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 the mov eax,5 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.
Press the F10 key (called Step Over) to execute the current statement. Continue pressing F10 until the program is about to execute the invoke 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:
download code view debugger for masm32 book
Soon you will want to display CPU registers when debugging your programs. Here's how to make them visible: First, under the Tools >> Options menu, select Debbuging in the left panel, and select Enable address-level debugging. Next, set a breakpoint in your source code on an executable statement, run your program in Debug mode, select Windows from the Debug menu, and then select Registers from the drop-down list. If you do not see the Registers command in the Debug >> Windows drop-down menu (which seems to be the case for the VS2017 Community Edition, there is a way to add a Registers command button to your Debug toolbar. Here's how to do it: While not debugging, select Customize from the Tools menu.
Click the Commands tab, select the Toolbar tab, and selectDebug from the list of toolbars.
Click the Add Command button. In the Categories list, select Debug.
Select Registers from the list of commands, click the OK button to close the dialog window.
Click the Close button to close the Customize dialog. You should nowsee a new button on the Debug toolbar that looks like a small rectangle containing "0X" when you begin debugging a program.
The Registers window may appear docked to the top of the workspace, but you may find it helpful to float the window on top of your workspace. Just grabthe window header with the mouse and pull it to the center area. You will alsowant to display the CPU flags. To do that, right click inside the Registers window and check the word Flags from the popup menu. 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 maroon-colored square button on the toolbar. To remove a breakpoint from a program, click its red dot to make it disappear.A reminder, you might want to review our tutorial:Using the Visual Studio debuggerBuilding 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.
Write a test program. You can copy the code from below. I adapted the code from the wonderful book : Assembly Language for x86 Processors by Kip Irvine. I highly recommend this book for anyone start learning the Assembly language.
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 the mov eax,5 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. (Optionally, you can close the Diagnostic Tools, Autos, and Call Stack windows.)
Press the F10 key (called Step Over) to execute the current statement. Continue pressing F10 until the program is about to execute the invoke statement.
A small black window icon should appear on either your Windows desktop or status bar. 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:
Soon you will want to display CPU registers when debugging your programs. Here's how to make them visible: First, under the Tools >> Options menu, select Debbuging in the left panel, and select Enable address-level debugging. Next, set a breakpoint in your source code on an executable statement, run your program in Debug mode, select Windows from the Debug menu, and then select Registers from the drop-down list. If you do not see the Registers command in the Debug >> Windows drop-down menu (which seems to be the case for the VS2019 Community Edition, there is a way to add a Registers command button to your Debug toolbar. Here's how to do it: While not debugging, select Customize from the Tools menu.
Click the Commands tab, select the Toolbar tab, and selectDebug from the list of toolbars.
Click the Add Command button. In the Categories list, select Debug.
Select Registers from the list of commands, click the OK button to close the dialog window.
Click the Close button to close the Customize dialog. You should nowsee a new button on the Debug toolbar that looks like a small rectangle containing "0X" when you begin debugging a program.
The Registers window may appear docked to the top of the workspace, but you may find it helpful to float the window on top of your workspace. Just grabthe window header with the mouse and pull it to the center area. You will alsowant to display the CPU flags. To do that, right click inside the Registers window and check the word Flags from the popup menu. 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 maroon-colored square button on the toolbar. To remove a breakpoint from a program, click its red dot to make it disappear.A reminder, you might want to review our tutorial:Using the Visual Studio debuggerBuilding 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.
(2) Insert the OPTION M510 directive in your program prior to the line(s) causing the syntax error. Q7 When I try to assemble a program in the Assembler Editor (AE.EXE), I see the message "Error A2901: cannot run ML.EXE". Why does this happen? See FAQ #Q3. Q8 Where can I get a copy of the source code for the link library (IRVINE.LIB)? You can get a copy from your instructor, if they permit. Only they can download it from the Instructor's Web site. If you are not currently taking an assembler course, you can still contact a university professor near you who knows your situation. If they decide to release some or all of the source code to you, it's their privelege. I'm sorry that this is an inconvenience, but the library contains many of the solutions to programming exercises. Q9 Why doesn't the Sector Display program on p. 406 display any sectors when I run it from Drive C? This program was designed to work on a FAT-16 file system. Windows NT and Windows 98 both have a FAT 32 system, so the program will have to be updated. Until then, you can still run it on a floppy disk formatted under Windows 95. Q10 Why does the assembler generate an error message when I use 32-bit registers? You need to place the .386 directive in your program on the line following the .stack directive. This was not clearly explained in the book, but there is a reference to the .386 directive in Table 2 on page 93. Q11 How do I use the book's link library with the Borland Turbo Assembler (TASM)? You can modify the editor configuration file (AE.CFG), or write a simple batch file. Click here for more details. Q12 How does Windows 95/98/NT store extended (long) filenames? The book, on page 402, does not adequately explain this. Click here to view an improved example and explanation of extended filenames. Q13 How can I access the help files that were installed with MASM 6.11? The Help files supplied with MASM are a wonderful reference, not only on assembly language syntax, but also on using the Assembler (ML.EXE), CodeView, the Linker, and other utilities. You can access help from the Programmers Workbench (PWB.EXE), from CodeView (CV.EXE), or from a stand-alone help program named QuickHelp (QH.EXE). From the C:\MASM613\BIN directory, type the following two commands at the DOS prompt: NEW-VARS QH Q14 How can I generate a listing file when assembling programs? If you're using ML.EXE to assemble programs, include the /Fl option on the command line (that's a lowercase "L" character following "F", not the number one). When using the Assembler Editor (AE.EXE), choose Set Pathnames from the Run menu, and insert /l in the Assembler Command-Line Options edit box (that's slash-el, not slash-one, by the way...). Q15 Would you suggest some good IDEs (integrated development environments) for creating assembly language programs? There are several. Click here to view a summary. Q16 Is there some way to purchase the MASM manuals? We've been told that the manuals are no longer available for purchase from Microsoft. But there is a very good online help system available with MASM, called QuickHelp (see FAQ #Q13). Q17 How is the INCLUDE directive used? The INCLUDE directive allows you to insert the contents of another source code file into the input stream when your current file is assembled. On the sample programs CD, for example, we supply an include file that contains all of the EXTRN directives to match the book's link library. Click here to see a sample program that uses the LIBRARY.INC file. The file being INCLUDEd should either be in the same directory as your main program, or you must supply a relative path so the assembler can find it. For example, INCLUDE ch08\macros.inc Q18 How can I use the Macro library from Chapter 8? The Macro library is in a file named MACROS.INC, listed on page 298 of the book. Copy this file from the sample programs directory (C:\IRVINE) to the same directory as your ASM program. Insert the following statement in your program just before the .data directive: INCLUDE macros.incAlternatively, you can specify the complete pathname for the macro libary and leave the MACROS.INC file in the C:\IRVINE directory: INCLUDE c:\irvine\macros.inc 2ff7e9595c
Comentários