Write a MASM assembly code to calculate the following 5 6

Write a MASM assembly code to calculate the following ((5 + 6) * (11 - 8) / 3) mod 3 using 32 bit assembly

code so far:

.data
var1 dword 0
var2 dword 0
var3 dword 0
var4 dword 0

.code
main proc
   mov   eax,   5              
   add   eax,   6  
   mov var1,   eax
      
   mov ebx,   11
   sub ebx,   8
  
   mov ecx,   3
   div ebx; //** overflow error occurs, very stuck

**haven\'t gotten to modulo 3

please help, online course with no instructor assitance.

Solution

.data
var1 dword 0
var2 dword 0
var3 dword 0
var4 dword 0

.code
main proc
     mov    eax,    5               
     add    eax,    6   
     mov var1,    eax
        
     mov ebx,    11
     sub ebx,    8

xor edx edx. // it sets edx to zero first

mov ecx, 3

div ecx //This divides the contents of ebx with 3 which is stored in ecx

mov var2,ebx //quotient will be stored in ebx which is moved to var2

mul ebx

xor edx,edx

move ecx,3

div ecx

mov var3,edx //moves the remainder to var3

The result will be stored in var3

Write a MASM assembly code to calculate the following ((5 + 6) * (11 - 8) / 3) mod 3 using 32 bit assembly code so far: .data var1 dword 0 var2 dword 0 var3 dwo

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site