Chat Box

Showing posts with label Assembly. Show all posts
Showing posts with label Assembly. Show all posts

Saturday, February 21, 2009

MASM Syntax Highlighting In Visual Studio

MASM syntax highlighting in Visual Studio

When a text editor uses syntax highlighting, language keywords, strings, and other elements appear in different colors. Visual Studio and Visual C++ Express can highlight MASM reserved words and strings, as shown in the following example:

This won't happen automatically, but you can create a syntax definition file named Usertype.dat that contains MASM keywords. Then when Visual Studio (or Visual C++ Express) starts, it reads the syntax file and highlights MASM keywords.

Here are the required steps to set up MASM syntax highlighting in Visual Studio or Visual C++ Express:

1) Download the Usertype.dat file given here to a folder in which you have read/write permissions. If you are using Windows Vista, download to My Documents, or C:\temp, or any folder that doesn't have security restrictions.

2) Copy Usertype.dat to the C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE folder. If you are using Windows Vista, it will display a verification window before copying the file.

3) Open Visual Studio or Visual C++ Express, select Options from the Tools menu, select Text Editor, and select File Extension. On the right side of the dialog (shown below), enter asm as the extension, select Microsoft Visual C++ from the Editor list, and click the Add button. Click the OK button to save your changes.

Close Visual Studio and restart it. Open your project and display an ASM file. You should see syntax highlighting in the editor.

How To Use Visual Studio For Running Assembly Code

You might be interested to know more about how Visual C++ projects are set up for assembly language programs. Follow the following steps to use .Net Framework to assemble your assembly code. First of all install VS 2005 or VS 2008 complete and extract the content of irvine.exe
Download Irvine.exe for VS 2005
Download Irvine.exe for VS 2008

Now open Visual Studio and choose File -> New -> Project .

Select Visual C++ in left column and Empty Project in Right Column. Give a name to your project i.e. "Project 1" and click OK.


Right Click on the project in Solution Explorer and Choose "Custom Build Rules". or open it from Project menu i.e . Project -> Custom Build Rules


Int that Dialog Box mark "Microsoft Macro Assembler" as checked. and click OK


Now open Add New Item dialog box by right clicking in the solution explorer and choosing Add -> New Item.. Or you can also open Add New Item dialog box from toolbar button.

In Add New Item dialog box choose Code from left column and C++ File(.cpp) from right column. and give it any name with .asm extension. Like i have given it a name main.asm. Remember .asm extension is necessary.


Now select Project Properties from the Project menu. Expand the entry under Configuration Properties. Then expand the entry named Microsoft Macro Assembler. This is what you should see:

Click the entry named General under Microsoft Macro Assembler . Notice that the Include Paths option has been set to the c:\Irvine directory. This tells the assembler where to find files having a filename extension of ".inc". Here is a sample:

Find the Linker entry under Configuration Properties. Select the Input entry, and notice that two filenames have been added to the Additional Dependencies entry. The user32.lib file is a standard MS-Windows file. The irvine32.lib file is the link library file supplied with this book. There must be at least one space separating the file names:

Next, select Linker under Configuration Properties, and then select General. The Additional Library Directories option equals c:\Irvine, so the linker can find the Irvine32.lib library file:

Select Linker under the Configuration Properties and select Debugging. Notice that the Generate Debug Info option is set to Yes:

Select System under the Linker entry. Notice that the SubSystem option has been set to Console:

We use the Console setting because it is easy for assembly language programs to write output to a text console (Command) window. This is the window you see when running cmd.exe from the Start > Run menu in Windows.

Click the OK button to close the Project Property Pages window.


Now you have set up correctly so do start coding but remember to write the first line of code as

INCLUDE irvine32.inc

Friday, February 13, 2009

Assembly Tutorials

X86 Assembly

This is an open content wiki book about assembly language programming. The book includes sections on the history of the X86 architecture, the X86 family and programming in X86 assembly.


MIPS Assembly

This is the wikibooks entry for MIPS assembly that discusses the MIPS architecture and MIPS programming.


Programmed Introduction to MIPS Assembly Language

This is a course in assembly language programming of the MIPS processor. It emphasizes the topics needed for study of computer architecture: bits, bit patterns, operations on bit patterns, and how bit patterns represent instructions and data.


Learning Assembly

A beginner-level tutorial that introduces assembly language.


Win32 Assembler Coding Tutorial

This site also has some additional assembler and programming resources that you can access from the drop down menus at the top of the page.


101% Assembler

This site is dedicated to assembly language programming. It features some assembler tool downloads and source code examples.


Programming from the Ground Up (1.4 Mb PDF file)

A book on assembly for the newbie to the pro. It covers how the cpu works as well as writting programs.


Introduction to Assembly Language

This web page examines assembly languages in a general manner. Specific examples of addressing modes and instructions from various processors are used to illustrate the general nature of assembly language.


Assembly Language Tutor

This is an introduction for people who want to program in assembler language.


The Art of Assembly Language Programming

Online book available for Windows, DOS and Linux assembly programming. Teaches High Level Assembly (HLA) - you will need to download the HLA compiler and supporting files.


PC Assembly Tutorial

The tutorial has extensive coverage of interfacing assembly and C code and so might be of interest to C programmers who want to learn about how C works under the hood. All the examples use the free NASM (Netwide) assembler.


Assembly Language Programming

PowerPoint and HTML Presentations on Various Assembly Language Topics.


Assembly Tutorial

This is for all you folks out there, who want to learn the magic art of Assembly programming.


Linux Assembly

If you are looking for information on assembly programming under UNIX-like operating systems, this is the right place to be. Here you can find various resources, ranging from tutorials and documentation, to actual programs written in assembly language.


Linux Assembly "Hello World" Tutorial

Designed to familiarize the reader with programming in x86 assembly under Linux and how to interface assembly and higher-level language code. The tutorial will also briefly cover debugging your assembly using GDB.

Wednesday, February 4, 2009

Assembly Language Notes Of Virtual University


Virtual University of Pakistan


Assembly Language Notes

Download

Monday, February 2, 2009

How to run Assembly Programs in Visual Studio

First, you must install some version of Visual Studio or Visual C++ Express:
  1. If you have installed Visual Studio 2008 Professional or Team Suite, these products also contain the Microsoft Assembler 9.0.
  2. If you have installed Visual C++ 2008 Express Service Pack 1, it includes the Visual C++ 2008 Feature Pack, which also includes MASM 9.0.
  3. If you have installed Visual C++ 2005 Express, you must also download the Microsoft Assembler 8.0
    (see below).
Downloading Microsoft Express Editions

When you run the setup program for either of these, make a note of the location where the C++ compiler is installed. This information will be useful to you later.

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 Example Programs

The latest copy of the example programs are listed below.


Example programs and link libraries (designed for Visual Studio 2008) New
Example programs and link libraries (designed for Visual Studio 2005)

The examples are stored in a self-extracting archive file that automatically extracts to the c:\Irvine folder. Unless you have some objection to using that location, do 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 will 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 will 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 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. 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:

  1. Start Visual Studio or Visual C++ Express.
  2. 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.
  3. Navigate to the c:\Irvine\Examples\Project_Sample folder and open the file named Project.sln.
  4. 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 the View menu. Also, if you do not 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 this program and use it as a starting point to write your own programs.

Build the Program

Next, you will build (assemble and link) the sample program:

  • If you're using Visual C++ Express, select Build Solution from 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 screen, you should see messages similar to the following, indicating the build progress:

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 do not see these messages, the project has probably not been modified since it was 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 will be larger than the one shown here:

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

Congratulations, you have 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 was created inside the project's \Debug folder. This is the file that executes when you run the project. You can execute Project.exe by double-clicking its name inside Windows Explorer, but it will just flash on the screen and disappear. That is because Windows Explorer does not pause the display before closing the command window.

Creating New Projects of Your Own

Before long, you will want to create your own projects. The easiest way to do this 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 will set a breakpoint inside the sample program. Then you will use the Visual C++ debugger to step through the program's execution one statement at a time.

  1. To begin stepping through your program in Debug mode, press the F10 key.
  2. A yellow arrow will appear next to the first program statement (call Clrscr).The arrow indicates that the statement is next to be executed.
  3. Press the F10 key (called Step Over) to execute the current statement. Continue pressing F10 until the program is about to execute the exit statement.
  4. 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.
  5. Press F10 one more time to end the program.

Registers

If you want to display the CPU registers, do the following: Start debugging the program, then select Windows from the Debug menu. Select Registers from the drop-down list. The bottom window will display the register contents. Right click this window and check the item Flags to 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 on the red dot so that 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 that point, the debugger drops into single-step mode.

  1. Click the mouse along the border to the left of the call WriteString statement. A large red dot should appear in the margin.
  2. 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.
  3. Press F10 until the program finishes.

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

Building and Running Other Programs

Suppose you want to run another example program, or possibly create your own program. You can either edit and modify main.asm, or you 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, select 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 key. Or, you can right-click the file name and select Remove.

Adding a File to a Project

The easiest 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. A reference to the file (not a copy) will be inserted in your project's directory. Try this now:

  1. Remove the main.asm file from your project.
  2. Add a reference to the file c:\Irvine\Examples\ch03\AddSub.asm to the project.
  3. Build and run the project.

Here is what you should see in the Console window, except that only your EAX register will have the same value as ours:

When you press a key, the console window will close.

Copying a source file

If you want to make a copy of an existing file, 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.

Friday, January 16, 2009

Assembly Language for Intel-Based Computers (4th Edition) By Kip R. Irvine

http://pixhost.ws/media/images/Assembly%20Lang.gif


Description:
Designed for students and professionals interested in learning the basics of operating systems and architecture in the context of a microprocessor. Irvine shows how to approach programming problems with a machine-level mindset. Readers will benefit most if they have already learned a high-level language such as C, Delphi, or Java.

Software: Includes a full professional version of Mcft Assembler 6.11 (MASM). Also supplied are a large link library of console I/O routines, and a custom-designed programming editor from which you can assemble, link, and debug programs.

Examples: Over 50 complete example programs are supplied, including protected-mode subroutines that link to Mcft Visual C and Borland C.

Topics: Binary and hexadecimal tutorials, hardware and software architecture, instruction set fundamentals, procedures and interrupts, stack parameters, conditional processing, logic structures, integer arithmetic, structures and macros, numeric conversions and libraries, strings and arrays, disk storage, finite state machines, low-level disk I/O, hardware port I/O, linking to C programs, memory-resident programs, and floating-point instructions.–This text refers to an out of print or unavailable edition of this title.

From the Back Cover:
This text is designed for students and professionals interested in learning the basics of operating systems, architecture, and programming in the context of a microprocessor. In his eagerly anticipated fourth edition, Kip Irvine concentrates on the combined Windows/MS-DOS operating system and thoroughly covers 32-bit assembly language applications for Intel-based computers.
Focusing on how to approach programming problems with a machine-level mindset, Assembly Language for Intel(r)-Based Computers includes the following features:
Detailed tutorials on numbering systems and data storage fundamentals.
All programs tested with the Mcft(r) MASM 6.15(tm) assembler.
Inline assembly code, as well as linking assembly language to C/C in both Real and Protected modes.
Extensive instruction set reference that includes instruction formats and CPU flag usage.
Interrupt vectoring and device I/O.

CD-ROM that includes the full professional version of the Mcft(r) MASM 6.15(tm) Assembly Language Development System, a programmer’s editor, a macro library, and the book’s source code.

New to the fourth edition:
  1. Win32 programming, including the console API and a graphical application.
  2. Expanded coverage of procedures, recursion, stack parameters, structures, and unions.
  3. Boolean expressions, truth tables, and flowcharts.
  4. Basic string handling, sorting and searching algorithms.
  5. Bit-mapped graphics in both Real and Protected modes.
  6. IEEE floating-point binary representation.
  7. Virtual machine architecture; IA-32 Protected mode segmentation and paging.
  8. Introductory explanations of the instruction execution cycle, memory I/O, multitasking, pipelining, and superscalar architecture.
  9. Disk fundamentals, including disk geometry, FAT32 and NTFS file structures.


Download Link :
For book:
http://rapidshare.com/files/50941060/5A35E5B4-4E82-40BB-A1FD-C03AC9CF40DA.rar
Password: books_for_all

For CD:
http://rapidshare.com/files/51578843/C74BFA11-004E-4b5f-8B5C-70AC3F624C52.rar
Password: books_for_all