Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

assembly language: Using registers the program will add, A = ((A-B)+(A+D))+C. A

ID: 3870694 • Letter: A

Question

assembly language:

Using registers the program will add, A = ((A-B)+(A+D))+C. A is EAX register with value of 20, B is EBX register with value of 10, C is ECX register with value of 30, D is EDX register with value of 15. The answer should be 75. Store result in memory variable named finalVal. Out put should be in decimal.

INCLUDE Irvine32.inc

.data

finalSum dword?

.code

main PROC

   move eax, 20

   move ebx, 10

   move ecx, 30

   move edx, 15

   add ebx, edx

   add finalVal        ;stores result

   call DumpRegs   ;display the registers

   call WaitMsg       ;so it doesn't just close when finished running

   exist

main ENDP

END main   

Explanation / Answer

Code:-

INCLUDE Irvine32.inc

.data

finalVal dword?

.code

main PROC

move eax, 20

move ebx, 10

move ecx, 30

move edx, 15

add ebx, edx

sub ebx, edx

add eax,eax ;A=A+A i.e EAX=EAX+EAX

sub eax,ebx ;A=A-B+A i.e EAX=EAX-EBX

add eax,edx ;A=A-B+A+D i.e EAX=EAX+EDX

add eax,ecx ;A=A-B+A+D+C => A= ((A-B)+(A+D))+C i.e EAX=EAX+ECX

mov [finalVal],eax ;stores result

call DumpRegs ;display the registers

call WaitMsg ;so it doesn't just close when finished running

exist

main ENDP

END main

Explanation :-

Equation is first resolved :- A= ((A-B)+(A+D))+C => A = A+A-B+C+D