title: How to index malloc'd buffer and output
body: <p>See <a href="http://pastebin.com/wgKd74Xh" rel="nofollow">full code here</a>.</p>
  
  <p>I have filled a buffer (malloc'd) with an <code>fread</code> call and it is a success. I am now trying to iterate over the buffer and commence parsing the input. I'm trying to start really simple by walking the buffer and output each char to the screen. But my loop is just outputting the entire input. Here is the loop portion of the code:</p>
  
  <pre><code>mov     ecx,    0
  mov     ebx,    buffer
  .readByte:
      push    DWORD   [ebx + 1 * ecx]
      push    DWORD   ecx
      push    DWORD   char
      call    _printf
      add     esp,        12
  
      incr    ecx
  
      cmp     ecx,        [fsz]
      jge     .endRead
  
      jmp     .readByte
  </code></pre>
  
  <p>The contents of the source file that is read in (s1.txt) is:</p>
  
  <blockquote>
    <p>1 + 2;</p>
  </blockquote>
  
  <p>My goal is to simply output:</p>
  
  <blockquote>
    <p>1  </p>
    
    <p>+</p>
    
    <p>2<br>
    ;</p>
  </blockquote>