Question

How does the nested For implementation compare to the standard For implementation in the assembly language...

How does the nested For implementation

compare to the standard For implementation in the assembly language using masm

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Let me illustrate how nested for is implemented in the assembly language using masm:

for(var i =0 ; i< 10 ; i++){

    for(var j = 0 ; j<10;j++){

         s=i+j;

    }

}

In masm, this can be written as

      mov ecx, 0

      outerLoop:

              cmp ecx , 10

              je done

             mov ebx, 0

      innerLoop:

             mov eax,ecx

             add eax,ebx

             cmp ebx,10

             je innerLoopDone

         inc ebx

             jmp innerLoop

   innerLoopDone:

               inc ecx

              jmp outerLoop

   done:

We can understand this code easily,firstly cmp means compare ,inc means incrementing the value by 1 and je means jump if equal .The above for loop is thereby programmed in masm .In standard for loop also , we write in the similar manner putting Loop control over there .And the operations to be performed are then done in the loop control.

Add a comment
Know the answer?
Add Answer to:
How does the nested For implementation compare to the standard For implementation in the assembly language...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT