80x86 Intro to Assembly Language - I am just trying to make sure I have this ans
ID: 642441 • Letter: 8
Question
80x86 Intro to Assembly Language - I am just trying to make sure I have this answer correct.
Here is the problem:
1. The following code utilizes a while loop. Assume that sum references a doubleword in the data segment and that count is in the ECX register. Give a fragment of 80x86 cod that implements the design.
sum := 0;
count := 100;
while (sum<1000) or (count >= 0) loop
add count to sum;
subtract 1 from count;
end while;
Here is what I have come up with:
mov ecx,0 ; set ECX register =0
mov eax,4 ; set EAX register = 4
whilesum:
cmp sum,1000 ; subtract total value of the SUM to 1000
add ecx,eax ; Add value of EAX register into ECX register
sub ecx,1 ; subtract 1 from ECX register
jnl endwhilesum ; jump to endwhilesum label if not less than 1000
endwhilesum:
Am I missing anything or does this satisfy the question?
Explanation / Answer
Given code is maximum correct.
Modified code highlight(bold) in provided code:
mov ecx,0 ; set ECX register =0
mov eax,4 ; set EAX register = 4
whilesum:
cmp sum,1000 ; subtract total value of the SUM to 1000
jn1 endwhile ; exit loop if not
body: add ecx,eax ; Add value of EAX register into ECX register
sub ecx,1 ; subtract 1 from ECX register
jnl endwhilesum ; jump to endwhilesum label if not less than 1000
endwhilesum:
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.