stlink-common: Update STM32L0/1 loaders to return remaining count in r2
[fw/stlink] / flashloaders / stm32l0x.s
index 6c863c64aef7a869251c872675d319b5b767210b..fcbd06e396944d5853de798b07b51fe51dbc5b34 100644 (file)
     r2 - count
 */
 
-    // Set 0 to r3
-    movs    r3, #0
     // Go to compare
-    b.n test_done
+    b test_done
 
 write_word:
     // Load one word from address in r0, increment by 4
     ldr    r4, [r0]
     // Store the word to address in r1, increment by 4
     str    r4, [r1]
-    // Increment r3
-    adds    r3, #1
+    // Decrement r2
+    subs    r2, #1
        adds    r1, #4
        // does not matter, only first addr is important
        // next 15 bytes are in sequnce RM0367 page 66
        adds    r0, #4
 
 test_done:
-    // Compare r3 and r2
-    cmp     r3, r2
+    // Test r2
+    cmp     r2, #0
     // Loop if not zero
     bcc.n    write_word