Answer to Question #175176 in C++ for Kent

Question #175176

Implement c++ 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

 

         if (value < 1000)

                    value = value+10*count;

         else {

                    value = 800;

                    count--;

}


1
Expert's answer
2021-03-24T12:46:00-0400

            mov  eax, 10             ; eax = 10

           mov ecx, count        ; load count to ecx

 

           cmp value, 1000      ; compare value with 1000

           jl      Then_                ; if(value<1000) goto Then_

                                               ; else

           mov  value, 800        ; value:=800

           dec count                 ; subtract 1 from count

           jmp End_If              ; goto End_If

Then_:

           mul  ecx                     ; 10*count

           add value, eax          ; value = value + 10*count

End_If:


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS