title: Write an ARM Assembly Language program to compute the nth Fibonacci number
body: <p>I am just starting out in programming and computing and got an assignment thats really confusing me. it has two parts
  1.Write an ARM Assembly Language program to compute the nth Fibonacci number. The
  nth Fibonacci number is defined recursively as:
  Fn= Fn-1 + Fn-2
  where F0 = 0 and F1 = 1.
  Use R2 for n and compute Fn in R0. Test your program by computing F16 and F32.
  2. Using your answer to Q1 as a starting point, write an ARM Assembly Language program
  to calculate the largest possible Fibonacci number using (i) 32-bit unsigned arithmetic
  and (ii) 32-bit signed arithmetic. Make sure you report the values of n and Fn (in
  hexadecimal and decimal) in your project submission.</p>
  
  <p>if (MAX - Fn-1 &lt; Fn-2) // Fn-1 + Fn-2 will be greater than MAX…
  break; // therefore Fn-1 is the largest Fibonacci number</p>
  
  <p>So far I have:</p>
  
  <pre><code>        AREA    RESET, CODE, READONLY
          ENTRY
  
  start   MOV     R1, #16     ; n = 16
          MOV     R3, #0      ; fn1 = 0
          MOV     R0, #1      ; fn = 1
          MOV     R2, #1      ; curr = 1
  whn     CMP     R2, R1      ; while (curr &lt; 1)
          BHS     endwhn      ; {
          ADD     R2, R2, #1  ;   curr = curr + 1
          MOV     R4, R0      ;   tmp = fn
          ADD     R0, R0, R3  ;   fn = fn + fn1
          MOV     R3, R4      ;   fn1 = tmp
          B       whn         ; }
  endwhn
  
  STOP    B       STOP
  
          END
  </code></pre>