title: Multiplication in assembly with negative number and result
body: <p>I am fairly new in Assembly,
  and I am having a hardtime dealing with negative number</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  void main() {
      short int mat1[] = {-1,-2, 4,5, 4,-2}; // first array
      short int mat2[] = {2,0,0,0, 0,2,0,0}; // second array
      int mat3[1024]; // result array
  
      __asm {
          MOV AX, mat1[0] ; mat1[0]:= -1
          MOV BX, mat2[0] ; mat2[0]:= 2
          ; my problem is how i can do this
          ; mat3[0] = mat1[0] * mat2[0] ;
          ; (operation result -&gt; mat3[0] = -2)
      }
  }
  </code></pre>
  
  <p>p.s. This is for my homework 
  thanks in advance</p>
  
  <hr>
  
  <p>New Question:</p>
  
  <p>After try some assembly operation:</p>
  
  <pre><code>MOV AX, mat1[ECX]   ; eax is 0 and mat1[ecx] is -1
  </code></pre>
  
  <p>but after this operation
  how come AX is set to 65535 and not to -1?
  How can I do proper multiplication then if AX register is not correct?
  I am quite confuse how to handle complement of 2.</p>
  
  <hr>
  
  <p>I got another question.
  currently I have this code where I move <strong>IMUL</strong> result to array.</p>
  
  <pre><code>    MOV WORD PTR mat3[ECX*4]+0, AX 
      MOV WORD PTR mat3[ECX*4]+2, DX
  </code></pre>
  
  <p>My Question is how can I add the IMUL result to the current Array[idx] value?</p>
  
  <p>with this where mat3[current index] = 0, the operation is correct.
  but when for example mat3[current index] = -2, I a different number to what I expect to get.</p>
  
  <pre><code>    ADD WORD PTR mat3[ECX*4]+0, AX 
      ADD WORD PTR mat3[ECX*4]+2, DX
  </code></pre>
  
  <p>I thank you in advance for your help</p>