Reference no: EM132591696 , Length: 5 pages
Problem 1. Implement each design given below. Assume that value is stored as a doubleword in memory, number is in EAX, and count is in ECX. You need only show the assembly code for the design. Submitting entire programs is not necessary.
(a)
if value ≤ 1000
then
add number*count to value;
end if;
(b)
if value < 1000
then
add 10*count to value;
else
value := 800;
subtract 1 from count;
end if;
(c)
if (value ≥ 100)
then
add 5*count to value;
end if;
(d)
if value < 1000
then
add number*count to value;
else
value := 800;
end if;
(e)
if value > 1000
then
subtract number*count from value;
else
value := 500;
end if;
Problem 2. Implement each design given below. Assume that value is stored as a doubleword in memory, number is in EAX, and count is in ECX. You need only show the assembly code for the design. Submitting entire programs is not necessary.
(a)
number := 0;
value := 500;
while number ≤ 60 and value > 200 loop
subtract number from value;
add 5 to number;
end while;
(b)
while (count < 100) and (value ≤ 500) loop
add count to value;
add 2 to count;
end while;
(c)
while (count < 100) or (value ≤ 500) loop
add count to value;
add 2 to count;
end while;
(d)
number := 0;
value := 500;
while number ≤ 100 or value > 300 loop
subtract number from value;
add 5 to number;
end while;
Problem 3. Implement each design given below. Assume that value is stored as a doubleword in memory, number is in EAX, and count is in ECX. You need only show the assembly code for the design. Submitting entire programs is not necessary.
(a)
count := 0;
value := 50;
repeat
add 1 to count;
add count to value;
until count > 20 and value ≥ 300;
(b)
repeat
value := 2*value;
add 1 to count;
until (value > 1000);
(c) count := 0;
value := 50;
repeat
add 1 to count;
add count to value;
untilcount > 10 or value ≥ 150;
Problem 4. What will EAX contain following execution of the following code?
mov eax, 0 ; sum := 0
mov ecx, 4 ; count := 4
for4:
add eax, ecx ; add count to sum
loop for4
Problem 5. Modify the program in Figure 5.9 of our text (Detmer), replacing the second loop by one that changes each number that is larger than the average to zero. Show your full source code and screenshots of your working program.