title: Pointers in assembly language
body: <p>I am trying to understand how to use pointer in assembly. By reading some tutorials around internel,I think had undertantood some concepts. But when I'II go to try it,it did work. Below some attempts to translate C to ASM.</p>
  
  <p><strong>C</strong></p>
  
  <pre><code>const char *s = "foo";
  unsigned z = *(unsigned*)s;
  if(!(z &amp; 0xFF))
  do_something();
  if(!(z &amp; 0xFFFF))
   do_b_something();
  </code></pre>
  
  <p>(here's not full code,but it's a word-check,thefore,there is more two stmts which checks 0xFF0000,0xF000000 respectivily.</p>
  
  <p><strong>ASM:</strong></p>
  
  <pre><code>mov ebp,str
  mov eax,ebp
  
  mov eax,[eax]
  and eax,0xFF
  cmp eax,0
  je etc
  
  mov eax,[eax]
  and eax,0xFFFF
  cmp eax,0
  je etc
  </code></pre>
  
  <p>It returns a seg fault.</p>
  
  <p>And the try:</p>
  
  <pre><code>mov eax,dword ptr [eax]
  </code></pre>
  
  <p>that's generated by gcc compiler and you can see it in some other assemblies code,returns </p>
  
  <p><code>invalid symbol</code></p>
  
  <p>on FASM assembler. It isn't really supported by the FASM or am I missing something?</p>