Форум ReidS Soft

Информация о пользователе

Привет, Гость! Войдите или зарегистрируйтесь.


Вы здесь » Форум ReidS Soft » Примеры на ассеблере » Отладка программ на masm в Visual Studio


Отладка программ на masm в Visual Studio

Сообщений 1 страница 3 из 3

1

Отладка программ на masm в Visual Studio 6.0, 2012, 2013. http://www.kipirvine.com/asm/
Using Microsoft Visual Studio 6.0  http://www.kipirvine.com/asm/4th/ide/vs … tm#Debug32
Creating a Combined C++/Assembly Language Project http://www.kipirvine.com/asm/4th/ide/vs … /index.htm
Getting Started with MASM and Visual Studio 2012 http://www.kipirvine.com/asm/

Ассемблер для Windows используя Visual Studio. http://habrahabr.ru/post/111275/

Updated 5/29/2014. Our new tutorial for Visual Studio 2013 should be available by May 1, 2014.

This tutorial shows you how to set up Visual Studio 2012 (including Visual Studio 2012 Express for Windows Desktop) to work with Microsoft MASM. Visual Studio 2012 Express for Windows Desktop is a free download from Microsoft at http://www.microsoft.com/visualstudio/e … s-products

Additional topics:
Using the Visual Studio debugger
MASM syntax highlighting
Assembling, linking, and debugging with a batch file
Creating a Project from Scratch
The book's example programs in Chapters 1-14 have been successfully tested in Windows XP, 32-bit Vista and the 32-bit version of Windows 7. On the other hand, many programs in Chapters 15-17 will not run in any Microsoft OS later than Windows 98, because they rely on direct access to hardware and system memory. You cannot directly run 16-bit applications in any 64-bit version of Windows.

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 Studio Express....

Using Microsoft Visual Studio 6.0

Updated: 09/16/2002
This document explains how to configure Microsoft Visual Studio 6.0 for editing, debugging, and running assembly language programs.

Some important guidelines to follow before continuing with the instructions on this page:
We will assume that you have installed the assembler in the C:\Masm615 directory.
The 16-bit linker supplied with MASM does not permit filenames longer than eight characters, excluding the extension. The same goes for the directory name holding the program.
Make sure your source filenames have .ASM extensions and they are no longer than eight characters (not counting the extension).

The following is a simplified listing, minus all the remark (REM) lines of make16.bat: PATH C:\Masm615
SET INCLUDE=C:\Masm615\INCLUDE
SET LIB=C:\Masm615\LIB

ML /nologo -c -Fl -Zi %1.asm
if errorlevel 1 goto terminate

LINK /nologo /CODEVIEW %1,,NUL,Irvine16;
if errorlevel 1 goto terminate

DIR %1.*
:terminate
pause

Build 16-bit MASM
Run the Visual C++ 6.0 integrated development environment. First, we will create the Tools command to assemble and link your MASM programs:

Select Customize from the Tools menu and click on the Tools tab.

Scroll to the bottom of the Menu Contents text area and double click inside the dotted rectangle. Type the following name and press Enter:
Build 16-bit MASM

Enter the following information in each edit box. The Arguments entry is case-sensitive, including the variables such as $(FileName) and $(FileDir). Note the spacing very carefully! Within the Arguments line, leave at least one space after /C, and a space before $(FileName): If you're using Windows 98 or Windows Millenium, click here.

Debug 16-Bit MASM

Add the following new command to the tools menu:
Debug 16-bit MASM

Enter the following values:

Build 32-bit MASM

Add the following new command to the tools menu:
Build 32-bit MASM

The Arguments entry is case-sensitive, including the variables such as $(FileName) and $(FileDir). This following screen snapshot is only for Windows 2000 or Windows XP. Enter the following information in each edit box: If you're using Windows 98 or Windows Millenium, click here.

Note the spacing very carefully! Within the Arguments line, leave at least one space after /C, and a space before $(FileName).
DEBUG 32-Bit MASM

Add the following new command to the tools menu:
Debug 32-bit MASM

Enter the following values:

Notice the browse (...) button to the right of the Command entry--use this button to navigate to the location of msdev.exe on your computer.
Run MASM

Add the following new command to the tools menu:
Run MASM


(If you are using Windows 95/98/ME, insert command.com for the Command entry rather than CMD.EXE.)

Close the Customize window.
Test your configuration

Now either create a new ASM program and save it with an ASM extension, or open an existing ASM file. If you need help on this step, click here.

Select Build 16-bit MASM from the Tools menu. You should see messages from the Microsoft Assembler appear in the output window. If you've made any errors, fix them and assemble the program again until it's right.

Once the program builds correctly, you can run the program. Select RUN MASM from the Tools menu.

Next, select Debug 16-bit MASM from the Tools menu. Microsoft CodeView will run, and after a few seconds, your source program will appear. (Refer to Appendix C of the Irvine book for help in using CodeView, and look at the CodeView Debugger Help page on this Web site.)

You have finished customizing the Visual C++ Editor.

Build 16-bit MASM (Windows 98 or Millenium)

Windows 98 and Windows Millenium use Command.com as their command-line processor. The following screen snapshot shows the command and parameters you should use: Note that an extra argument (/E) was used here to increase your MS-DOS environment size. This reduces the likelihood of an "Out of Environment Space" error message when you run the make16.bat file.

Continue to the Debug16 Step

Build 32-bit MASM (Windows 98 or Millenium)

Windows 98 and Windows Millenium use Command.com as their command-line processor. The following screen snapshot shows the command and parameters you should use: Note that an extra argument (/E) was used here to increase your MS-DOS environment size. This reduces the likelihood of an "Out of Environment Space" error message when you run the make32.bat file.

Continue to the Debug32 Step

0

2

Если ничего не получилось, попробуйте мой исправленный вариант.

Построение и отладка Masm32-приложения без ресурсов в Visual Studio v6.0

Создайте файл make32.bat и  скопируйте в c:\masm32

SET PATH=C:\masm32\bin
SET INCLUDE=C:\masm32\INCLUDE
SET LIB=C:\masm32\LIB

del *.obj
ML /nologo -c /coff /Cp -Fl -Zi %1.asm
if errorlevel 1 goto terminate

LINK /nologo /SUBSYSTEM:WINDOWS /DEBUG /DEBUGTYPE:CV %1.obj
if errorlevel 1 goto terminate

DIR %1.*
:terminate
pause

Как вы знаете, для сборки файла с ресурсами необходимо добавить строку для компиляции ресурсов и указать файл
откомпилированных ресурсов в качестве параметра линкера. 

Создайте новые пункты меню Tools как описанов статье http://www.kipirvine.com/asm/4th/ide/vs … m#Debug32:
Build 32-bit MASM
DEBUG 32-Bit MASM
Run MASM

Необходимо отметить, что пока все операции по построению, отладке и запуску приложения на masm32 будут осуществляться без участия стандартного меню Build.
Окройте IDE VC 6.0 и создайте новый пустой проект (консольное приложение) с именем Demo1.
Добавьте в проект новый файл Hello.asm. Текст приведен ниже. Откройте его в IDE и постройте с помощью пункта меню

Tools->Build 32-bit MASM
В каталоге Demo1 вы получите файлы:
HELLO.exe
HELLO.ilk
HELLO.lst
HELLO.obj
HELLO.opt
HELLO.pdb

Теперь можно запустить HELLO.exe  с помощью пункта меню Tools->Run MASM.

Для запуска отладки выберите пункт меню Tools->DEBUG 32-Bit MASM. Откроется новый экземпляр IDE VC 6.0.
Вы можете нажать F11 или выбрать пункт меню Debug->Start Debug->Step Into, но такой вариант отладки менее нагляден.
Поэтому откройте файл HELLO.ASM в меню File->Open File
Поставьте снова точки останова, тк они остались в первом экземпляре IDE. 
Пошаговая отладка программы выполняется стандартным способом, клавишами F10,F11.

;Файл Hello.asm
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

;                 Build this with the "Project" menu using
;                       "Console Assemble and Link"

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

    .486                                    ; create 32 bit code
    .model flat, stdcall                    ; 32 bit memory model
    option casemap :none                    ; case sensitive

    include \masm32\include\windows.inc     ; always first
    include \masm32\macros\macros.asm       ; MASM support macros

  ; -----------------------------------------------------------------
  ; include files that have MASM format prototypes for function calls
  ; -----------------------------------------------------------------
    include \masm32\include\masm32.inc
    include \masm32\include\gdi32.inc
    include \masm32\include\user32.inc
    include \masm32\include\kernel32.inc

  ; ------------------------------------------------
  ; Library files that have definitions for function
  ; exports and tested reliable prebuilt code.
  ; ------------------------------------------------
    includelib \masm32\lib\masm32.lib
    includelib \masm32\lib\gdi32.lib
    includelib \masm32\lib\user32.lib
    includelib \masm32\lib\kernel32.lib

.data

szMess db "Hey, this actually works.",13,10,0

    .code                       ; Tell MASM where the code starts

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

start:                          ; The CODE entry point to the program

    invoke MessageBox,0,addr szMess,0,MB_OK
    invoke ExitProcess,0

; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««

end start                       ; Tell MASM where the program ends

;;;Жаль, что Стив Хатчесон не знает.

0

3

*Для запуска отладки выберите пункт меню Tools->DEBUG 32-Bit MASM. Откроется новый экземпляр IDE VC 6.0.

Все же существует возможность использовать стандартный пункт меню Debug->Start Debug.
Но для этого потребуется внести некоторые незначительные изменения в настройки проекта. :)
Удачи.

0


Вы здесь » Форум ReidS Soft » Примеры на ассеблере » Отладка программ на masm в Visual Studio