title: Linked List Implementation ARM7
body: <p>I am currently using Keil uVision4 and I am trying to implement a linked list that will go through a preset list and stop only when it either reaches the end or it finds a value that matches what is in register r0. I have debugged my code and noticed that during the first run through of the loop, the initial LDR r0, [r0] stores the value inside the first node in r0, but in the second time it comes to go through the loop, it loads 0x00000000 into r0 when it executes LDR r0, [r0]. I'm trying to figure out how it can go to the next node in the list rather than return a zero value. </p>
  
  <pre><code>    AREA question1, CODE, READONLY
      ENTRY
      ;--------------------------------------------------------------------------
          LDR r1, =0x12347777
          ADR r0, List            ;r0 points to the first element in list
  Loop    LDR r4, [r0]            ;places the next pointer in r0
          CMP r0, r1
          LDR r0, [r0, #4]
          BEQ Store
          CMP r0, #0x00           ;checks if it is the end of the linked list
          BNE Loop                ;if its not the end of the list, then     continue reading the next node
  
          LDR r2, =0xF0F0F0F0     ;Failure, set register r2
          B fin
  
  Store   MOV r2, #0xFFFFFFFF     ;Success, set register r2
          LDR r3, [r0]            ;Success, store pointer in r3
  
  fin     B fin
  </code></pre>
  
  <p>;---------------------------------------------------------------------------</p>
  
  <pre><code>        AREA question1, DATA, READWRITE
  
  List  DCD 0x12341111, Item5
  Item2 DCD 0x12342222, Item3
  Item3 DCD 0x12343333, Item4
  Item4 DCD 0x12344444, Item6
  Item5 DCD 0x12345555, Item2
  Item6 DCD 0x12346666, Item7
  Item7 DCD 0x12347777, 0x00      ;terminator
  ;---------------------------------------------------------------------------
          END
  </code></pre>