62.6k views
4 votes
What will be the final value of EAX in this example? mov eax,0 mov ecx,10 ; outer loop counter L1: mov eax,3 mov ecx,5 ; inner loop counter L2: add eax,5 loop L2 ; repeat inner loop loop L1 ; repeat outer loop

User HVenom
by
5.3k points

1 Answer

2 votes

Answer:

eax = 28.

Step-by-step explanation:

The given code in question will not end. The following code is correct version. eax will be 28 in both scenarios.

mov eax, 0 ; Unnecessary as next instruction changes this

L1: push ecx ; This and the pop below solves the problem

mov eax, 3

mov ecx, 5

L2: add eax, 5

loop L2

pop ecx

loop L1 ; ECX is decremented first

User Juri Robl
by
5.1k points