Answer to Question #175174 in C++ for Kent

Question #175174

Implement the following C++ expression in assembly language, using 32-bit signed operands:

  val1 = (val2/val3)*(val1 – val2)


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

xor    edx, edx          ; edx = 0  befor imul

mov  eax, val2         ; eax = val2

mov  ebx, val3         ; ebx = val3

idiv   ebx                  ; eax = val2/val3

push eax                  ; save eax in stack

 

mov  ebx, val1        ; ebx = val1

sub   ebx, val2         ; ebx = val1 – val2

pop  eax                  ; restore eax = (val2/val3)

imul ebx                  ; eax = (val2/val3)*( val1 – val2)

mov var1, eax        ; save new val1


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