HW # 4: Theme: Debugging, Flags, Data Declarations Solution

$30.00 $24.90

Description

  1. What will be the value of EAX and sign flag after the following lines execute?

Mov eax, 6

Sub eax, 5 ;

B. Is it possible to set the overflow flag if you add a negative integer to a negative integer? Explain with examples where applicable.

C. Is it possible for both the sign and zero flags to be set at that same time? State reasons.

D. In the following code, the value in AL is intended to be a signed byte. Does the overflow flag help to determine whether the final value in AL is within a valid signed range? Explain.

mov al, -1 ;

add al, 130 ;

E. What will be the value of the parity flag after the following lines execute?

Mov al, 2

Add al, 5 ;

  1. Given the following data declarations:

.data

Alpha BYTE 1Ah, 2Bh, 3Ch, 4CH

Beta DWORD 11223344h

Delta DWORD 44332211h

Iota DWORD 434h

Zeta WORD 124h

  1. Write instructions that move Delta into ECX and then adds Beta to the same register

  1. Write a set of instructions that adds all the elements of the array Alpha into AL

  1. Write a set of instructions that moves Beta into EAX, adds the value stored in Zeta to the same register

  1. Write an instruction that moves the last two bytes in ALPHA into AX.

  1. What are the contents of AX subsequent to part D of this question?

  1. Fill in the requested register values after executions of the instructions:

Show the memory map.

.data

myBytes BYTE 11h, 22h, 33h, 44h

myWords WORD 1234h, 5678h, ABCDh, EF01h, 2345h

myDoubles DWORD AB23h, BC34h, CD54h, 8967h, 6F6Ah

myPointer DWORD myDoubles

.code

mov esi, OFFSET myBytes

mov ax, WORD PTR [esi+2] ; A. AX =

mov eax, DWORD PTR myWords ; B. EAX =

mov esi, myPointer

mov ax, WORD PTR [esi+8] ; C. AX =

mov ax, WORD PTR [esi+1] ; D. AX =

mov ax, WORD PTR [esi-6] ; E. AX =

  1. What is the value of ax after the follow:

.data

myArray DWORD 7 DUP (2), 21, 4, 65, 0CDE

.code

mov ax, TYPE myarray

mov ax, lengthof myarray

mov ax, sizeof my array

  1. Fill in the requested register values after executions of the instructions (Do not let your eyes deceive you. There are some movSx instructions and some movZx instructions.):

.code

mov bx, 0B24Ch

movzx eax, bx ; A. EAX =

movzx edx, bl ; B. EDX =

movzx cx, bh ; C. CX =

mov bx, 0D3C2h

movsx eax, bx ; D. EAX =

movsx edx, bl ; E. EDX =

movsx cx, bh ; F. CX =

  1. What will be the value of the destination operand after each of the following instructions execute?

.data

var1 SBYTE -4, -2, 3, 1

var2 WORD 1000h, 2000h, 3000h, 4000h

var3 SWORD -16, -42

var4 DWORD 1, 2, 3, 4

.code

mov ax, var2 AX =

mov ax, [var2+4] AX =

mov ax, var3 AX =

mov ax, [var3-2] AX =