-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patharraymove.s
More file actions
65 lines (41 loc) · 1.46 KB
/
arraymove.s
File metadata and controls
65 lines (41 loc) · 1.46 KB
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
.syntax unified
.cpu cortex-m4
.fpu softvfp
.thumb
.global Main
Main:
@
@ write your program here
@
CMP R2, R1 // if (fromIndex < toIndex)
BHS indexChange
LDR R9, [R0, R1, LSL #2] //storage = [startAddress+(toIndex]//
MOV R8, R2 //testIndex = fromIndex//
whileLoopA :
CMP R8, R1 // while(testIndex<=toIndex)
BHI TestB
LDR R7, [R0, R8, LSL #2] // storageA = [startAddress+(testIndex)]//
STR R9, [R0, R8, LSL #2] // storage =[startAddress+(testIndex*4)]
MOV R9, R7 // storage = storageA//
ADD R8, R8, #1 // testIndex++//
B whileLoopA // }
// }
indexChange :
CMP R2, R1 // else if (fromIndex > toIndex)
BLS TestA
LDR R9, [R0, R1, LSL #2] // storage = [startAddress+(toIndex*4)]//
MOV R8, R2 // testIndex = fromIndex//
whileLoopB :
CMP R8, R1 // while(testIndex>=toIndex)
BLT TestB
LDR R7, [R0, R8, LSL #2] // storageA =[startAddress+(testIndex)]//
STR R9, [R0, R8, LSL #2] // storage = [startAddress+(testIndex)]
MOV R9, R7 // storage = storageA//
SUB R8, R8, #1 // testIndex--//
B whileLoopB // }
// }
TestA :
TestB :
@ End of program ... check your result
End_Main:
BX lr