Vous êtes sur la page 1sur 21

1. Download masm from http://www.masm32.

com/

2. Unzip the package and run install.exe

3. Set the path to the compiler. pen !"# computer$% right click and select !&roperties$. Select !'d(anced$ )* !+n(ironment (aria,les$)*$&ath$. -lick !+dit$ and add !.c:/masm32/,in$ to the path

0. -heck the installation ,# opening the command prompt window 1Start)*2un)*cmd3

and t#ping "4 at the command prompt

5. Download 16),it (ersion of the link.exe from the "icrosoft7s we,site http://download.microsoft.com/download/(c15/Update/1/89:; </+:)US/4nk563.exe -op# this file to -:/"'S"32/=9: and run it. 'nswer >es when asked whether to o(erwrite existing files.

6. Download -ode ?iew De,ugger http://kipir(ine.com/asm/5th/c(/c(01patch.exe Unzip all files to c:/masm32/,in

@. :ow #ou can use almost an# text editor to create an assem,l# program. 9n this example% we will use "icrosoft7s +D9A. A#pe !edit example1.asm$ on the command prompt and enter the text of the program.

Sa(e the file ,# !'lt)B$%$'ltCS$. +xit !'lt)B$%!'lt)D$

<. -ompile and link the assem,l# file ,# issuing !ml /Ei example1.asm$

;. :ow lets start and configure the -ode ?iew de,ugger. A#pe !c( example1.exe7 at the command prompt. +nter !'lt)8$ and make sure that #ou ha(e the following windows on the screen: -ode 1 2egisters "emor# 1

&ress !'lt)B5$ to arrange the windows on the screen.

:ow lets set the options. !'lt) $ )* &references. Set the options as shown and click !ok$.

'gain% !'lt) $ )* !Source 1 window$

!'lt) $ ) *$"emor# 1 window$

Ahe configuration is now complete.

1F.

4ets look at the program.

11. :ow lets step through the program and o,ser(e execution of each instruction. &ress !B1F$. Ahe de,ugger will show execution of the first line of the prolog. &ress !B1F$ until instruction !" ? 'D%F$ is highlighted. Ahis is the first instruction of #our program.

,ser(e the (alue in the register +'D. 2egister 'D contains num,er F;DBG.

:ow press !B1F$. Ahe de,ugger will execute the highlighted instruction. :ote the change in the content of +'D and the fact that the register has ,een highlighted ,# the de,ugger% indicating the change.

Ahe highlighting the code window mo(ed to the next instruction. :ote that the line of the source code !" ? '4% ?'21$ ,ecame !" ? '4% HFFF-I where FFF-G is the actual offset of ?'21 in the data segment. >ou can check that this is true ,# checking the content of memor# location DS:FFF-G in the data window.

:ow execute this instruction ,# pressing !B1F$. -ontent of the register '4 changed% taking the (alue from the ?'21.

Ahe next instruction is !" ? =D% BBS+A ?'22$. ?'22 follows ?'21 in memor# and has offset of FFFDG. Ahis is the (alue that will ,e placed into the =D upon execution of this instruction. &ress !B1F$ to execute.

Ahe following instruction !" ? H=DI% '4$ will cop# the content of '4 into the memor# location pointed ,# =D within the data segment. 'fter the pre(ious instruction =D contains the offset of the first ,#te of ?'22 or FFFDG. Ahat is where the data from '4 will appear. &ress !B1F$ to execute. :ote the de,ugger also highlighted changes in the data window.

9nstruction !" ? H=DC1I% '4$ will cop# the content of the register '4 into the memor# location with offset eJual whate(er the num,er is in =D plus 1. 9n our case =DKFFFDG% then the offset is FFFDGCFFF1GKFFF+G. Ahat is the second ,#te of the ?'22. &ress !B1F$ to execute. :ote the change in the memor# content.

9nstruction !" ? +'D% 123056@<G$ will place num,er 123056@<G into the register +'D. &ress !B1F$ to execute.

Ahe instruction !" ? ?'23% +'D$ ,ecame !" ? D8 2D &A2 HFFFBI% +'D$. ?'23 has ,een replaced ,# the actual offset 1FFFBG3 of ?'23 in the data memor#. Ahis instruction will take the content of the +'D and place into the four consecuti(e ,#tes of memor# 1a 32),it (aria,le3 starting with the offset FFFBG. &ress !B1F$ to execute.

Ahat was the last instruction of the user program. Ahe remaining instructions are generated ,# the .+D9A directi(e and ser(e to terminate the program. &ress !B1F$ until the process terminates.

Still not clear how to work with the -ode?iew de,uggerL Gere is additional tutorials #ou can go through.

-ode?iew tutorial http://www.nu(isionmiami.com/,ooks/asm/c(/index.htm

De,ugging http://www.math.uaa.alaska.edu/MafkNm/cs221/handouts/de ,ugging.pdf

Vous aimerez peut-être aussi