Question

Convert the C++ Source code into Assembly Language (MASM) Code: int sum = 0, k =...

Convert the C++ Source code into Assembly Language (MASM) Code:

int sum = 0, k = 1;

while ( k < = 20 )

{

if ( k % 2 == 0 )

sum + = k;

k++;

}

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

Here I am converting the lines of C++ code into masm.

mov dword ptr [sum], 0

mov dword ptr [k], 1

cmp dword ptr [k], 14h

jg main+63h

mov eax, dword ptr [k]

and eax, 80000001h

jns main+4Bh

dec eax

or eax, 0FFFFFFFEh

inc eax

test eax, eax

jne main+58h

mov eax, dword ptr[sum]

add eax, dword ptr [k]

mov dword ptr [sum], eax

mov eax, dword ptr [k]

add eax, 1

mov dword ptr [k], eax

jmp main+36h

Add a comment
Know the answer?
Add Answer to:
Convert the C++ Source code into Assembly Language (MASM) Code: int sum = 0, k =...
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