Write a loop that iterates through a doubleword array and calculates the sum of
ID: 645685 • Letter: W
Question
Write a loop that iterates through a doubleword array and calculates the sum of its elements using a scale factor with indexed addressing.
WriteasequenceoftwoinstructionsthatsetboththeCarryandOverflowflagsatthesametime.
Write a sequence of instructions showing how the Zero flag could be used to indicate unsigned overflow after executing INC and DEC instructions.
Write a single instruction that moves the first two bytes in myBytes to the DX register. The resulting value will be 2010h.
all in one listing file
Explanation / Answer
Ans1.
array sqword 20 dup (0) ; int array[20];
mov eax, 0
mov ecx, 0
loop_start:
cmp ecx, 20
jge loop_end
add eax, array[ecx*4]
add ecx, 1
jmp loop_start
loop_end:
--------------
Ans2.
mov eax, F000h
add eax, F000h
This will generate both Carry and Overflow flags
--------------
Ans.3
mov eax, FFFFh
inc eax
This will result in Zero flag to indicate unsigned overflow.
And,
mov eax, 0001h
dec eax
This will result in Zero flag to indicate unsigned overflow.
OR
mov al,0FFh
inc al
jz overflow_occurred
mov bl,1
dec bl
jz overflow_occurred
http://quizlet.com/30041297/assembly-quiz-4-flash-cards/
-------------
Ans4.
mov dx, WORD PTR myBytes
Ref: http://site.iugaza.edu.ps/ayash/files/Assembly-Chapter4_Part2.pdf
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.