title: Converting a string of numbers into an integer in Assembly x86
body: <p>I'm trying to convert a user inputted string of numbers to an integer.</p>
  
  <p>For example, user enters "1234" as a string I want 1234 stored in a DWORD variable.<br>
  I'm using <code>lodsb</code> and <code>stosb</code> to get the individual bytes. My problem is I can't get the algorithm right for it. My code is below:</p>
  
  <pre><code>mov ecx, (SIZEOF num)-1
  mov esi, OFFSET num
  mov edi, OFFSET ints
  cld
  
  counter:
     lodsb
     sub al,48
     stosb
     loop counter
  </code></pre>
  
  <p>I know that the <code>ECX</code> counter is going to be a bit off also because it's reading the entire string not just the 4 bytes, so it's actually 9 because the string is 10 bytes.</p>
  
  <p>I was trying to use powers of 10 to multiply the individual bytes but I'm pretty new to Assembly and can't get the right syntax for it. If anybody can help with the algorithm that would be great. Thanks!</p>