-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathboot-test.s
66 lines (63 loc) · 2.12 KB
/
boot-test.s
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
.data
.balign 4
a: .skip 0x00100000
.text
.global main
main:
mov r0, #0 /* Setting r0 = 0 */
ldr r1, addr_of_a /* r1 = &a */
mov r2, #0 /* r2 = 0 (r2 is counter) */
ldr r4, =0x00000000 /* r4 = 0 */
sub r8, r4, #1 /* r8 = 0 - 1 : 1 */
ldr r6, =0x00040000 /* Setting r6 to a quarter of MB */
initialLoop1:
cmp r2, r6 /* Checking to see if a mb has been written */
beq reset1 /* If so, leave the loop, otherwise continue */
add r3, r1, r2, LSL #2 /* r3 = r1 + (r2*4) */
str r8, [r3] /* *r3 = r8 */
add r2, r2, #1 /* r2 = r2 + 1 */
b initialLoop1 /* Go to the beginning of the loop */
reset1:
ldr r2, =0x00000000 /* Resetting counter */
b read1
read1:
cmp r2, r6 /* Checking if loop is finished */
beq reset3 /* Go to reset */
add r3, r1, r2, LSL #2 /* r3 = r1 + (r2*4) */
ldr r10, [r3] /* r10 = r3 */
cmp r10, r8 /* Check if r10 equals r8 */
add r2, r2, #1 /* Increment counter */
bne error1 /* If not match then go to error */
b read1 /* Loop */
reset3:
ldr r2, =0x00000000 /* Resetting counter */
b initialLoop2
initialLoop2:
cmp r2, r6 /* Checking to see if a mb has been written */
beq reset2 /* If so, leave the loop, otherwise continue */
add r3, r1, r2, LSL #2 /* r3 = r1 + (r2*4) */
str r4, [r3] /* *r3 = r4 */
add r2, r2, #1 /* r2 = r2 + 1 */
b initialLoop2 /* Go to the beginning of the loop */
reset2:
ldr r2, =0x00000000 /* Resetting counter */
b read2
read2:
cmp r2, r6 /* Checking if loop is finished */
beq end /* Go to end */
add r3, r1, r2, LSL #2 /* r3 = r1 + (r2*4) */
ldr r10, [r3] /* r10 = r3 */
cmp r10, r4 /* Check if r10 equals r4 */
add r2, r2, #1 /* Increment counter */
bne error /* If not match then go to error */
b read2 /* Loop */
end:
mov r0, #0 /* Print 0 when program ends */
bx lr
error1:
mov r0, #1 /* Print 1 when program ends */
bx lr
error2:
mov r0, #2 /* Print 2 when program ends */
bx lr
addr_of_a: .word a