Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Lab 2 – 60-266 – how to use the debugger in assembly

OBJECTIVES:

  1. i) To learn how to build and test a source program written in assembly language.
  2. ii) To learn how to use the debugger.

The program lab2.asm is given below. We will use the debugger to add and remove breakpoints, and correct errors in the program. Then we will assemble, link and run the program.

 

STEP 1: Create a text file lab2.asm as given below.

STEP 2: Open  Visual Studio  and select Open à Project/Solution from the File menu.

STEP 3: Navigate to C:\Irvine\examples\Project_sample\ folder and open the file name Project.sln. In the Solution Explorer window, click the mouse next to the item named Project to expand it.

STEP 4: Right-click on main.asm in the Solution Explorer window. In the context menu, select Exclude from Project.

STEP 5: Drag your lab2.asm file with the mouse from a Windows Explorer window onto the name of your project in the Solution Explorer window. Double-click the file named lab2.asm to open it in the Editor window.

STEP 6: Select Build Project from the Build menu and fix any errors detected by the Assembler.

STEP 7: Insert a “Break” in the program, at the mov eax, val1 statement, by clicking on the left border.

STEP 8: Display the register window by selecting Windows à Registers from the Debug menu.

STEP 9: Check the values of val1 and val2 in the watch window.

STEP 10: Use F10 key to step through the program. View the contents of registers and variables at each step.

 

Answer the following questions:

What location (offset) is the instruction  sub ecx, 500h  stored in?

What  is the content of register eax before executing instruction  mov eax, val1

What is the content of register eax after executing instruction  mov eax, val1

Answer:

INCLUDE Irvine32.inc

.data
val1 dword 4040h
val2 word 1555h
val3 byte "Hello World", 0
.code
main PROC
	mov EDX, offset val3
	call WriteString
	call crlf

	mov eax,val1
	add ax,val2	; error correction: eax changed to ax
	mov cx, val2	; error correction: ecx changed to cx
	sub ecx, 500h
	mov ebx, 3000h
	add eax,ebx	; error correction: bx changed to ebx
	sub ax,cx
	add val2, cx

	mov eax, 1111h
	add val1, eax

	call DumpRegs

	exit
main ENDP
END main  

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!