aboutsummaryrefslogtreecommitdiff
path: root/contrib/loaders/flash/stm32lx.S
blob: 8f9fd0b2b21d778ed98e098aa0beb6a6a9f696e8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/***************************************************************************
 *   Copyright (C) 2010 by Spencer Oliver                                  *
 *   spen@spen-soft.co.uk                                                  *
 *                                                                         *
 *   Copyright (C) 2011 Øyvind Harboe                                      *
 *   oyvind.harboe@zylin.com                                               *
 *                                                                         *
 *   Copyright (C) 2011 Clement Burin des Roziers                          *
 *   clement.burin-des-roziers@hikob.com                                   *
 *                                                                         *
 *   Copyright (C) 2017 Armin van der Togt                                 *
 *   armin@otheruse.nl                                                     *
 *                                                                         *
 *   This program is free software; you can redistribute it and/or modify  *
 *   it under the terms of the GNU General Public License as published by  *
 *   the Free Software Foundation; either version 2 of the License, or     *
 *   (at your option) any later version.                                   *
 *                                                                         *
 *   This program is distributed in the hope that it will be useful,       *
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 *   GNU General Public License for more details.                          *
 *                                                                         *
 *   You should have received a copy of the GNU General Public License     *
 *   along with this program; if not, write to the                         *
 *   Free Software Foundation, Inc.,                                       *
 *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
 ***************************************************************************/


// Build : arm-eabi-gcc -c stm32lx.S
	.text
	.syntax unified
	.cpu cortex-m0
	.thumb
	.thumb_func
	.global write

/*
	r0 - destination address
	r1 - source address
	r2 - count
*/

	// r2 = source + count * 4
	lsls	r2, r2, #2
	adds	r2, r1, r2
	// Go to compare
	b	test_done
write_word:
	// load word from address in r1 and increase r1 by 4
	ldmia r1!, {r3}
	// store word to address in r0 and increase r0 by 4
	stmia r0!, {r3}
test_done:
	// compare r1 and r2
	cmp	r1, r2
	// loop if not equal
	bne	write_word

	// Set breakpoint to exit
	bkpt	#0x00