title: LC-3 Program to Count occurrences of a char in a string
body: <p>I am trying to write a LC-3 program that will count the number of occurrences of a char that the user inputs in a string that is hard coded. The part that I am having trouble on is testing if the two characters equal each other, and I am also having trouble moving the next character in the string to test it. 
      ;Program to count occurrences of a char in a string</p>
  
  <pre><code>.ORIG   x3000
  LD  R3, POSASC  ;Loads R3 with #48
  LD  R4, NEGASC
  LD  R1, word    ;R1 = word
  
  ADD R6, R6, #5  ;Length of word
  GETC            ;Gets the char
  OUT         ;Prints the char
  ADD     R2, R2, R0  ;Stores the char in R2
  ;ADD    R2, R2, R4  ;To ascii
  AND R0, R0, #0  ;set R0 back to 0
  LOOP    
  AND     R5, R2, R1  ;check if char is equal
  ADD     R1, R1, #1  ;increment to next char in word
  ADD R6, R6, #-1 
  BRnp    LOOP
  
  ADD R0, R0, R5  ;Set R0 to # of occurrences
  OUT         ;Print # of occurrences
  
  HALT
  POSASC  .FILL   x0030       ;#48
  word    .STRINGZ "hello"    ;word to count occurrences of a char
  NEGASC  .FILL   xFFD0       ;#-48
  .END
  </code></pre>