aboutsummaryrefslogtreecommitdiff
path: root/AT91SAM7S256/armdebug/Debugger/debug_test.S
blob: 2cb87a0d5d91440d05119b89f2efb130bf03f5b5 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
/** @file debug_test.S
 *  @brief Test Routines to trigger ARM and Thumb Manual Breakpoints
 *
 */

/* Copyright (C) 2007-2011 the NxOS developers
 *
 * Module Developed by: TC Wan <tcwan@cs.usm.my>
 *
 * See AUTHORS for a full list of the developers.
 *
 * See COPYING for redistribution license
 *
 */
#define __ASSEMBLY__
#include "debug_stub.h"

.text
.align 4
.code 32

/**********************************************
 * dbg__test_arm_bkpt Test Routine
 *
 */
	dbg_interwork dbg__test_arm_bkpt
	stmfd sp!,{lr}
	dbg__bkpt_arm                  /* Trigger ARM Manual Breakpoint */
    ldmfd sp!,{pc}


/**********************************************
 * dbg__test_arm_instrstep Test Routine
 *	Used to test GDB Stepping command
 *	This routine exercises the mov, add, ldr, ldm, b, bl,
 *	and bx instructions which modify the PC (R15)
 *	In addition, conditional instructions are also evaluated.
 *
 */
	dbg_interwork dbg__test_arm_instrstep
	stmfd	sp!, {lr}
	bl		dbg__test_arm_instr_sub1
	ldr		r1, =test_arm_3			/* R1: pointer to test_arm_3 */
	ldr		r2, =test_arm_2			/* R2: pointer to test_arm_2 */
	mov		pc, r1

test_arm_1:
	subs	r0, r0, #1
	addne	pc, r2, #4				/* If R0 > 0, keep branching to a new location */
	/* else R0 == 0 */
	b		exit_dbg__test_arm_instrstep

test_arm_2:
	sub		r0, r0, #1
	cmp		r0, #5
	bgt		test_arm_1
	ldrle	pc, =exit_dbg__test_arm_instrstep
	b		exit_dbg__test_arm_instrstep

test_arm_3:
	sub		r0, r0, #1
	teq		r0, #8
	beq		test_arm_1
	ldrne	r3, =test_arm_3
	bx		r3

exit_dbg__test_arm_instrstep:
	bl		dbg__test_thumb_instr_sub1
	ldmfd	sp!, {pc}

	.global dbg__test_arm_instr_sub1
dbg__test_arm_instr_sub1:
	mov		r0, #10
	bx		lr

	.global dbg__test_arm_instr_sub1
dbg__test_arm_instr_sub2:
	stmfd	sp!, {r4, lr}
	mov		r0, #TRUE
	ldmfd	sp!, {r4, pc}

/**********************************************
 * dbg__test_thumb_bkpt Test Routine
 *
 */
	dbg_interwork dbg__test_thumb_bkpt
	stmfd sp!,{lr}
/*	ldr r0, =_thumb_entry
	orr	r0, r0, #1					@ Set Thumb mode
	mov	lr, pc
	bx	r0
*/
    bl  _thumb_entry
	ldmfd sp!,{pc}

.code 16
	.thumb_func
	.type _thumb_entry, %function
_thumb_entry:
	dbg__bkpt_thumb
	bx	lr


/**********************************************
 * dbg__test_thumb_instrstep Test Routine
 *	Used to test GDB Stepping command
 *
 */
	.global dbg__test_thumb_instrstep
	.thumb_func
	.type dbg__test_thumb_instrstep, %function
dbg__test_thumb_instrstep:
	push	{lr}
	bl		dbg__test_thumb_instr_sub1
	bl		dbg__test_thumb_instr_sub2

test_thumb_1:
	sub		r0, #1
	bne		test_thumb_2
	/* else R0 == 0 */
	b		exit_dbg__test_thumb_instrstep

test_thumb_2:
	sub		r0, #1
	cmp		r0, #5
	bls		test_thumb_1
	bhi		test_thumb_3
	beq		test_thumb_2
	b		test_thumb_1

test_thumb_3:
	sub		r0, #1
	cmp		r0, #0xB
	blo		load_test_thumb_1
	ldr		r2, =test_thumb_3+1		/* Need to set Thumb bit */
	b		exit_test_thumb_3
load_test_thumb_1:
	ldr		r2, =test_thumb_1+1		/* Need to set Thumb bit */
exit_test_thumb_3:
	bx		r2

exit_dbg__test_thumb_instrstep:
	bl		dbg__test_arm_instr_sub1
	pop		{r1}
	bx		r1

	.thumb_func
	.type dbg__test_thumb_instr_sub1, %function
dbg__test_thumb_instr_sub1:
	mov		r0, #0x0F
	bx		lr

	.thumb_func
	.type dbg__test_thumb_instr_sub2, %function
dbg__test_thumb_instr_sub2:
	push	{lr}
	mov		r1, #FALSE
	pop		{pc}


.end