top of page
Search
shendin1996

Assembly language for x86 processors: An in-depth and easy-to-follow tutorial (free pdf)



Assembly Language for x86 Processors, 7e is intended for use in undergraduate courses in assembly language programming and introductory courses in computer systems and computer architecture. This title is also suitable for embedded systems programmers and engineers, communication specialists, game programmers, and graphics programmers. Proficiency in one other programming language, preferably Java, C, or C++, is recommended.


Written specifically for 32- and 64-bit Intel/Windows platform, this complete and fullyupdated study of assembly language teaches students to write and debug programs at the machine level. This text simplifies and demystifies concepts that students need to grasp before they can go on to more advanced computer architecture and operating systems courses. Students put theory into practice through writing software at the machine level, creating a memorable experience that gives them the confidence to work in any OS/machine-oriented environment.




assembly language for x86 processors free pdf



Assembly Language for x86 Processors, Seventh Edition, teaches assembly language programming and architecture for x86 and Intel64 processors. It is an appropriate text for the following types of college courses:Assembly Language ProgrammingFundamentals of Computer SystemsFundamentals of Computer Architecture Students use Intel or AMD processors and program with Microsoft Macro Assembler (MASM), running on recent versions of Microsoft Windows. Although this book was originally designed as a programming textbook for college students, it serves as an effective supplement to computer architecture courses. As a testament to its popularity, previous editions have been translated into numerous languages. Emphasis of Topics This edition includes topics that lead naturally into subsequent courses in computer architecture, operating systems, and compiler writing:Virtual machine conceptInstruction set architectureElementary Boolean operationsInstruction execution cycleMemory access and handshakingInterrupts and pollingHardware-based I/OFloating-point binary representationOther topics relate specially to x86 and Intel64 architecture:Protected memory and pagingMemory segmentation in real-address mode16-Bit interrupt handlingMS-DOS and BIOS system calls (interrupts)Floating-point unit architecture and programmingInstruction encodingCertain examples presented in the book lend themselves to courses that occur later in a computer science curriculum:Searching and sorting algorithmsHigh-level language structuresFinite-state machinesCode optimization examples


Each assembly language file is assembled into an object fileand the object files are linked with other object files to forman executable. A "static library" is really nothing more thana collection of (probably related) object files. Applicationprogrammers generally make use of libraries for things likeI/O and math.


Sometimes you might like to use your favorite C libraryfunctions in your assembly code. This should be trivial becausethe C library functions are all stored in a C library, such aslibc.a. Technically the code is probably in a dynamiclibrary, like libc.so, and libc.a just hascalls into the dynamic library. Still, all we have todo is place calls to C functions in our assembly language program,and link with the static C library and we are set.


Visual Studio requires assembly language source files to belong to a project, 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 2019project 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:


  • 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.


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:


No doubt, you will want to assemble programs in various different disk folders, not just the batch_sample folder used in the foregoing example. All you need to do is copy the cmd.exe shortcut we gave you to your working directory, where your assembly language source files are located. When you double-click to run the shortcut, it will open a Command window in the current folder.


Assembly Language for x86 Processors, 7e is suitable for undergraduate courses in assembly language programming and introductory courses in computer systems and computer architecture. Proficiency in one other programming language, preferably Java, C, or C++, is recommended.


Written specifically for 32- and 64-bit Intel/Windows platform, this complete and fully updated study of assembly language teaches students to write and debug programs at the machine level. This text simplifies and demystifies concepts that students need to grasp before they can go on to more advanced computer architecture and operating systems courses. Students put theory into practice through writing software at the machine level, creating a memorable experience that gives them the confidence to work in any OS/machine-oriented environment.


Describe at a high level as if you are summarizing whatever C codecompiled to this assembly/machine code. (Feel free to write C todescribe what is computed.) Do mention a couple assembly detailsthat were particular aha! moments or red flags that alerted youto this high-level structure, but do not give a line-by-linerun-down of the assembly code. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Comments


bottom of page