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
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.w ip, [r0], #4
// Store the word to address in r1, increment by 4
str.w ip, [r1], #4
- // Increment r3
- adds r3, #1
+ // Decrement r2
+ subs r2, #1
test_done:
- // Compare r3 and r2
- cmp r3, r2
+ // Test r2
+ cmp r2, #0
// Loop if not zero
bcc.n write_word
r0, input, source addr
r1, input, dest addr
r2, input, word count
- r3, output, word count
+ r2, output, remaining word count
*/
- 0x00, 0x23,
0x04, 0xe0,
0x50, 0xf8, 0x04, 0xcb,
0x41, 0xf8, 0x04, 0xcb,
- 0x01, 0x33,
+ 0x01, 0x3a,
- 0x93, 0x42,
+ 0x00, 0x2a,
0xf8, 0xd3,
0x00, 0xbe
};
r0, input, source addr
r1, input, dest addr
r2, input, word count
- r3, output, word count
+ r2, output, remaining word count
*/
- 0x00, 0x23,
0x04, 0xe0,
0x04, 0x68,
0x0c, 0x60,
- 0x01, 0x33,
+ 0x01, 0x3a,
0x04, 0x31,
0x04, 0x30,
- 0x93, 0x42,
+ 0x00, 0x2a,
0xf8, 0xd3,
0x00, 0xbe
};
return -1;
}
- stlink_read_all_regs(sl, &rr);
-
/* check written byte count */
- if (sl->flash_type == FLASH_TYPE_L0) {
- if (rr.r[3] != count) {
- fprintf(stderr, "write error, count == %u\n", rr.r[3]);
- return -1;
- }
- } else {
- if (rr.r[2] != 0) {
- fprintf(stderr, "write error, count == %u\n", rr.r[2]);
- return -1;
- }
+ stlink_read_all_regs(sl, &rr);
+ if (rr.r[2] != 0) {
+ fprintf(stderr, "write error, count == %u\n", rr.r[2]);
+ return -1;
}
return 0;