This is program 4

Dependencies:   LCD_DISCO_F429ZI mbed TS_DISCO_F429ZI BSP_DISCO_F429ZI

Revision:
4:febba9dd921b
Parent:
3:2ec663c724ea
--- a/PROGRAM4_F20_Harrison.s	Mon Dec 07 18:45:28 2020 +0000
+++ b/PROGRAM4_F20_Harrison.s	Mon Dec 07 22:23:20 2020 +0000
@@ -25,22 +25,21 @@
     ;int32_t SumAllFrequencies()
 
 SumAllFrequencies
-    MOV R0, #0 ; track frequency num
+    MOV R4, #0 ; track frequency num
     LDR R1,= table ; get address of beginning of table
     MOV R3, #12 ; use 12 to account for word being first in table
-    LDRH R2, [R1, R3] ; get value where first frequency is stored in table
-    ADD R3, R3, #14
     B getFrequencyCount
 
 getFrequencyCount
     CMP R2, #0 ; compare value in table to 0
     BEQ leave ; break because looped through entire table
-    ADD R0, R0, R2 ; add current frequency to total frequency
     LDRH R2, [R1, R3] ; move R3 num of bytes in the table
+    ADD R4, R4, R2 ; add current frequency to total frequency
     ADD R3, R3, #14 ; add 14 bytes to R3
     B getFrequencyCount ; loop back
     
 leave
+    MOV R0, R4
     BX LR
 
     GLOBAL GetWordAt
@@ -70,17 +69,17 @@
     
 GetFreqAt
     MOV R1, #1
-    ADR R2, table ; get address of beginning of table
-    MOV R3, #8 ; use 8 to account for word being first in table
+    LDR R2,= table ; get address of beginning of table
+    MOV R3, #12 ; use 8 to account for word being first in table
     LDRH R4, [R2, R3] ; get value where first frequency is stored in table
-    ADD R3, R3, #12 ; use to move to next frequency in table
+    ADD R3, R3, #14 ; use to move to next frequency in table
     B findFrequency
     
 findFrequency
     CMP R1, R0 ; compare R1 to i
     BEQ frequencyFound ; break because frequency found
     LDRH R4, [R2, R3] ; move R3 num of bytes in table
-    ADD R3, R3, #12 ; add 12 bytes to R3
+    ADD R3, R3, #14 ; add 12 bytes to R3
     ADD R1, R1, #1
     B findFrequency