program 4 code

Dependencies:   LCD_DISCO_F429ZI mbed BSP_DISCO_F429ZI

Files at this revision

API Documentation at this revision

Comitter:
edwardjiang
Date:
Sat Dec 05 23:13:03 2020 +0000
Parent:
4:60bddeca288c
Commit message:
new code

Changed in this revision

assembly.s Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/assembly.s	Sat Dec 05 18:35:22 2020 +0000
+++ b/assembly.s	Sat Dec 05 23:13:03 2020 +0000
@@ -4,7 +4,7 @@
         GLOBAL getMax
 
 getMax  MOV R0,#0
-        ADR R1,table
+        ADR R1, table
         MOV R2,#8
         MOV R5, #0
         MUL R3, R5,R2
@@ -26,17 +26,18 @@
      
      
 
-        GLOBAL getTotFreq
+            GLOBAL getTotFreq
 getTotFreq  MOV R0, #0
-        ADR R1, table 
-        MOV R2,#8
-        MOV R5, #1
-        MUL R3, R2,R5
-        SUB R3, R3,#1
-        LDRSH R4, [R1,R3]
+            ADR R1, table 
+            MOV R2,#8
+            MOV R5, #1
+            MUL R3, R2,R5
+            SUB R3, R3,#1
+            LDRSH R4, [R1,R3]
         
 freqloop    CMP R4, #0
             BXEQ LR
+            
             ADD R0,R0, R4
             ADD R5,R5,#1
             MUL R3, R2,R5
@@ -57,10 +58,16 @@
             BX LR
             
             GLOBAL GetWordAt
-GetWordAt   
+GetWordAt   ADR R1, table 
+            MOV R2,#8
+            MUL R3, R0,R2
+            LDRSB R0, [R1,R3]
+            BX LR
+        
             
 quit BX LR
-        
+  
+stop B stop      
 
 table       DCB "pears",0
             DCW 8
--- a/main.cpp	Sat Dec 05 18:35:22 2020 +0000
+++ b/main.cpp	Sat Dec 05 23:13:03 2020 +0000
@@ -6,7 +6,7 @@
 DigitalOut led1(LED1);
 extern "C" uint32_t getMax();
 extern "C" uint32_t getTotFreq();
-extern "C" uint8_t * GetWordAt(int32_t i); 
+extern "C" uint8_t GetWordAt(int32_t i); 
 extern "C" int16_t GetFreqAt(int32_t i); 
 
 void button_pressed()
@@ -51,15 +51,17 @@
 
       uint16_t Xpos =100;
       for(int i=0;i<count;i++){
-          uint32_t word=0;
+          uint8_t word=GetWordAt(i);
           uint16_t wordFreq=GetFreqAt(i);
           float freq= wordFreq/totalFreq;
           sprintf((char*)text, "count=%d", count);
-          lcd.DisplayStringAt(i, LINE(i), (uint8_t *)&text, LEFT_MODE);
+          lcd.DisplayStringAt(0, LINE(0), (uint8_t *)&text, LEFT_MODE);
           sprintf((char*)text2, "Tfreq=%d", totalFreq);
-          lcd.DisplayStringAt(5, LINE(5), (uint8_t *)&text2, LEFT_MODE);
+          lcd.DisplayStringAt(6, LINE(6), (uint8_t *)&text2, LEFT_MODE);
 //          sprintf((char*)text, "freq=%d", wordFreq);
-//          lcd.DisplayStringAt(i, LINE(i), (uint8_t *)&text, LEFT_MODE);
+//          lcd.DisplayStringAt(i+1, LINE(i+1), (uint8_t *)&text, LEFT_MODE);
+//          sprintf((char*)text, "w=%d", word);
+ //         lcd.DisplayStringAt(i+1, LINE(i+1), (uint8_t *)&text, LEFT_MODE);
           
           uint16_t h=i*20;
           lcd.DrawRect(Xpos, 200, 20, h);