title: How do I perform bitwise multiplication/division in MASM x86 assembly?
body: <p>I have been tasked with writing a MASM x86 assembly program which multiplies/divides two 16 bit numbers by bit shifting. What I have so far is:</p>
  
  <pre><code>INCLUDE Irvine32.inc
  
  .data
  count BYTE -1
  val1  SDWORD  ?  
  val2  SDWORD  ?
  str1  BYTE "Enter Integer 1 here: ",0 ; 
  str2  BYTE "Enter Integer 2 here: ",0
  str3  BYTE "The product is: ",0
  mval WORD ?
  mval2 WORD ?
  pval WORD ?
  
  .code
  call clrscr
  main PROC
      mov dh,10
      mov dl,20
      call Gotoxy
      mov edx, OFFSET str1
      call WriteString
      call ReadInt
      mov mval,ax
  
      mov dh,12
      mov dl,20
      call Gotoxy
      mov edx, OFFSET str2
      call WriteString
      call ReadInt
      mov mval2,ax
  
      mov dh, 14
      mov dl, 20
      call Gotoxy
      mov edx, OFFSET str3
      call WriteString
      mov ax,pval
      call WriteInt
      call crlf
      call waitmsg
  
      mov eax,0
      mov ax,mval2
      mov ecx, 16
  
      L1:
      shr bx,1
      INC count
      JNC DontAdd
  
      push ecx
      mov ax,mval
      mov cl,count
      shl dx,cl
      add ax,dx
      pop ecx
  
      DontAdd:
      LOOP L1
      call waitmsg
      exit
  main ENDP
  END main
  </code></pre>
  
  <p>How would I correctly implement bitwise multiplication/division?</p>