title: Assigning value to variable in x86 (NASM)
body: <p>I have decided to learn assembler for fun. I have been coding in C for many years.</p>
  
  <p>I followed some online tutorials that print "Hello world" and dug around a bit in the NASM manual. All well and good. So, I set myself a task of printing "hello world" in a loop. I know I can do this with the <code>loop</code> opcode, but wanted to code it explicitly and use variables defined in the <code>.bss</code> section.</p>
  
  <p>However, I obviously misunderstand how variable assignment works in assembly as I get the error message:</p>
  
  <pre><code>nasm -felf -o hello.o hello.asm
  hello.asm:16: error: invalid combination of opcode and operands
  hello.asm:17: error: invalid combination of opcode and operands
  hello.asm:28: error: invalid combination of opcode and operands
  </code></pre>
  
  <p>I have tried searching the web for info on variable assignment, including the NASM manual, but can't seem to find the information I need. Can anyone assist? Here's my (simple!) code:</p>
  
  <pre><code>; print "Hello world!" to the screen multiple times
  
  section .data
      msg:    db  'Hello world!', 10
      msglen: equ $ - msg
  
  section .bss
      iter:   resb    1
  
  section .text
      global _start
  
  _start:
  
      ; loop 10 times
      mov iter, 0     ; initalise loop counter
  FL: cmp iter, 10    ; is iter == 10?
      jge LoopEnd
  
      ; write the message to STDOUT:
      mov eax,4       ; code for write syscall
      mov ebx,1       ; stdout fd
      mov ecx,msg     ; message to print...
      mov edx,msglen  ; ...and it's length
      int 80h         ; kernel interrupt
  
      ; increment loop iterator
      inc iter
      jp FL
  
  LoopEnd:
  
  
      ; now exit, with return code 0:
      mov eax,1
      mov ebx,0
      int 80h
  </code></pre>