title: How to check if number is even or odd in Assembler
body: <p>I wrote a code to check if a number is even or odd, but my program contains a endless loop and I can't really find it.</p>
  
  <p>Here are all Commands in the ISA:</p>
  
  <p><a href="https://i.stack.imgur.com/Nk8MG.png" rel="nofollow noreferrer">Commands Part 1</a><br>
  <a href="https://i.stack.imgur.com/8jJKl.png" rel="nofollow noreferrer">Commands Part 2</a></p>
  
  <p>Here is my Code:</p>
  
  <pre><code>#Read in Number
  addi zero t0 1
  sysmove exc t0
  syscall
  
  #Copy Number to a0
  sysmove a0 I[0]
  
  #check if number is even or odd
  ldd t1 zero 0
  ldd t2 zero 0
  ldd t3 zero 1 #Register contains 1
  ldd t4 zero 0 #Register contains 0
  
  #divide:
  subi a0 t2 2 # subtract with 2
  ldd t2 a0 0 #move to a0
  beq a0 t3 odd #compare a0 with 1
  beq a0 t4 even #compare a0 with 0
  jmp 6
  
  #odd:
  cout odd
  syscall
  
  #even: 
  cout even
  syscall
  </code></pre>