This repository has been archived by the owner on Jun 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworking_upload.txt
154 lines (139 loc) · 3.46 KB
/
working_upload.txt
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
.global asm_main
.align 4
memory: .space 2000000 ;@ 2MB reserved for own use throughout program
.align 4
Zmem: .space 2000000 ;@ 2MB for uploading Zprogram
.align 4
Zstack: .space 1000000 ;@ 1MB for Zstack
.align 4
FZreg: .space 1000000 ;@ 1MB for function local Zregisters
.align 4
temp: .space 256 ;@ 256B temporary storage for holding temp operands to variable operand count instructions
.align 4
asm_main:
;@ Set up transmitter to what TeraTerm is expecting
LDR R9, =0x20
LDR R4, =0xE0001004 ;@ Mode Register -- Tera Term transmitter
STR R9, [R4, #0]
;@ Start Baud rate setup
LDR R9, =0x3E
LDR R4, =0xE0001018 ;@ Baud rate generator
STR R9, [R4, #0]
;@ Complete baud rate setup
LDR R9, =6
LDR R4, =0xE0001034 ;@ Baud rate divider
STR R9, [R4, #0]
;@ Enable and reset the UART
LDR R9, =0x117
LDR R4, =0xE0001000 ;@ Control register
STR R9, [R4, #0]
;@ address of the sliding switches
LDR R1, =0x41220000
;@ read initial value of sliders
LDR R8, [R1, #0]
LDR R11, =memory
STR R8, [R11, #0] ;@ At the zero-th position in memory we store the current value of the sliders
MOV R4, #0
LDR R7, =Zmem ;@ FIXED VALUE DON'T CHANGE R7
LDR R10, =0 ;@ initial value of the receiver fifo store counter
STR R10, [R11, #4] ;@ At the fourth position in memory we store the current value of upload pointer
Check_switch:
LDR R1, =0x41220000 ;@ address of the sliding switches
LDR R8, [R11, #0] ;@ Getting the value of last state of sliders
LDR R10, =104800
LDR R9, [R1, #0]
CMP R9, R8
BEQ Check_switch
BNE Delay
Delay:
SUBS R10, R10, #1
BEQ Verify_switch
BNE Delay
Verify_switch:
LDR R9, [R1, #0]
LDR R10, =104800
CMP R8, R9
BEQ Check_switch
MOVNE R8, R9
LDRNE R11, =memory
STRNE R8, [R11, #0]
BNE Switch_changed
Switch_changed:
LDR R9, =128
AND R9, R8, R9
CMP R9, #128
BLEQ upload_mode
LDR R9, =64
AND R9, R8, R9
CMP R9, #64
BLEQ no_header_mode
BLNE header_mode
LDR R9, =128
AND R9, R8, R9
CMP R9, #128
BLNE run_mode
LDR R9, =32
AND R9, R8, R9
CMP R9, #32
BLEQ debug_mode
BLNE game_mode
LDR R1, =0x41220000 ;@ address of the sliding switches
LDR R11, =memory
LDR R8, [R11, #0]
LDR R9, [R1, #0]
CMP R8, R9
BEQ Switch_changed
BNE Check_switch
upload_mode:
PUSH {R8-R12, LR}
;@LDR R10, =Zmem
LDR R11, =2000000 ;@ Size of Zmem
LDR R8, =0 ;@ Zmem offset incrementor
LDR R9, =0 ;@ the null value to store at Zmem offset by R8
LDR R12, =1000000 ;@ Size of Zstack
//BL Delete_Zmemory
//BL Reset_Zstack
BL Check_receiver_fifo_and_store
POP {R8-R12, PC}
;@MOV PC, LR
Check_receiver_fifo_and_store:
LDR R9, =0xE000102C ;@ XUARTPS_SR_OFFSET
LDR R10, [R9]
TST R10,#2
BEQ Store
MOVNE PC, LR
;@BNE Check_receiver_fifo_and_store
Store:
LDR R8, =0xE0001030 ;@ Memory location where hello world is stored
LDRB R9, [R8] ;@ loading the input from UART memory location to R8
STRB R9, [R7, R4] ;@ Storing
ADD R4, #1
B Check_receiver_fifo_and_store
/*
Delete_Zmemory:
STR R9, [R7, R8]
ADD R8, R8, #1
CMP R11, R8
BPL Delete_Zmemory
LDREQ R8, =0
MOVEQ PC, LR
Reset_Zstack:
STR R9, [R10, R8]
ADD R8, R8, #4
CMP R12, R8
BPL Delete_Zmemory
LDREQ R8, =0
MOVEQ PC, LR
*/
run_mode:
MOV PC, LR
no_header_mode:
MOV PC, LR
header_mode:
MOV PC, LR
debug_mode:
MOV PC, LR
game_mode:
MOV PC, LR
done:
B done