title: NASM moving from memory to register and back not performing as expected
body: <p>I am new to assembly. In short I have no idea what I am doing and why the thing respond the way it does. I am using nasm, however I am not allowed to use any c functions. This has co compile and run using nasm assembly for intel x86 64bit. Here is some code:</p>
  
  <pre><code>    section .data
  
      x: dd 0
  
  section .text
      global _start
  
  _start:
      mov eax,0
      mov edi,0
      mov rsi,x
      mov edx,1
      syscall
  
      mov r9,x ;My problem was here, should be mov r9,[x]
      mov word [x],r9w 
  
      mov eax,1
      mov edi,1
      mov rsi,x
      mov edx,1
      syscall
  
      mov eax,1            ; The system call for exit (sys_exit)
      mov ebx,0            ; Exit with return code of 0 (no error)
      int 80h;
  </code></pre>
  
  <p>so all I am doing here is reading input from the console, saving that in x. then move that to register r9 and then back to x.</p>
  
  <pre><code>input 5
  </code></pre>
  
  <p>.</p>
  
  <pre><code>output 
  </code></pre>
  
  <p>I tried doing the normal xor, and mov r9,0. I can see that it does have get a value ass if I add 200, it gives me an output of </p>
  
  <pre><code>U
  </code></pre>
  
  <p>My only goal for doing this is to try and get a deeper understanding of how this works.
  thanx.</p>